导入不是导入所有函数?

2024-06-11 13:57:19 发布

您现在位置:Python中文网/ 问答频道 /正文

https://github.com/ezhome/django-webpack-loader

因为某种原因我导入网页包时_加载程序.utils就像在自述文件.md在repo中,它只导入get\ loader(我想要get\ static)。有人知道为什么会这样吗?你知道吗

我有一个视图,我正在尝试使用get\u 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_加载程序.utils'没有属性'get\u static'

如果我注释掉url代码,它将显示只加载get\ u loader。你知道吗

我不明白为什么要考虑这里的文件:https://github.com/ezhome/django-webpack-loader/blob/master/webpack_loader/utils.py

在shell中:http://imgur.com/a/E8BFs


Tags: djangofromhttpsimport程序githubcomurl
1条回答
网友
1楼 · 发布于 2024-06-11 13:57:19

考虑到这个问题没有引起注意,我建议使用pip并直接从github安装包:

$ pip install git+https://github.com/ezhome/django-webpack-loader.git

这是用pip安装第三部分包的另一种方法。该命令将直接从主分支下载源代码(因此您得到了最新的更改)。你知道吗

然后可以使用get\ u 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

相关问题 更多 >