[英]Import not importing all functions?
https://github.com/ezhome/django-webpack-loader
出於某種原因,當我在repo的README.md中導入webpack_loader.utils時,它只導入get_loader(我想要get_static)。 任何人都知道為什么會在這里發生?
我有一個視圖,我試圖使用get_static。
from webpack_loader import utils
def app(request):
url = utils.get_static('index')['url']
print (url)
import types
from inspect import getmembers, isfunction
print ('meow')
print ([o for o in getmembers(utils) if isfunction(o[1])])
這會引發錯誤:AttributeError:module'webpack_loader.utils'沒有屬性'get_static'
如果我注釋掉url代碼,則表明只加載了get_loader。
我很困惑為什么這會考慮這里的文件: https : //github.com/ezhome/django-webpack-loader/blob/master/webpack_loader/utils.py
在shell中: http : //imgur.com/a/E8BFs
鑒於問題沒有引起注意,我建議使用pip直接從github安裝包:
$ pip install git+https://github.com/ezhome/django-webpack-loader.git
這是使用pip安裝第三方軟件包的另一種方法。 該命令將直接從主分支下載源(因此您已獲得最新的更改)。
然后你可以使用get_static函數,例如
$ ./manage.py shell
Python 3.5.3 (default, Jan 29 2017, 01:40:30)
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from webpack_loader import utils
>>> utils.get_static
<function get_static at 0x7f8d56bc0ea0>
UPDATE
版本0.5.0已經發布,可能這個問題已得到修復。
更多信息: https : //github.com/ezhome/django-webpack-loader/issues/114
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.