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
答案 0 :(得分:0)
鉴于此问题没有引起注意,我建议使用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>
<强>更新强>
版本0.5.0已经发布,大概已经解决了这个问题。
更多信息:https://github.com/ezhome/django-webpack-loader/issues/114