3e81c3aadb9e838930c239b675ad71e7.png

关于同级目录下模块的引入问题请问为什么报错,

sys.path.insert(0,BASE_DIR)

将应用包加入系统变量, 便于模块导入

sys.path.insert(0,os.path.join(BASE_DIR, 'db_tools'))

sys.path.insert(0,os.path.join(BASE_DIR, 'apps'))

sys.path.insert(0,os.path.join(BASE_DIR, 'extra_apps'))

6a8dd179b1f14401d92b0c84314aca63.png

补充:

发现shell中引入没问题,但是外部文件中执行提示模块无法被引入

from goods.models import Goods

外部文件:

python models.py:

Traceback (most recent call last):

File "models.py", line 6, in

from goods.models import Goods

ModuleNotFoundError: No module named 'goods'

django,2.0的setting.py里INSTALLTED_APPS读不到自定义模块?

71c1918a015801691bdf3a5726ad2e61.png

filter_class = self.get_filter_class(view, queryset)

File "/root/Virtualenv/venv3_ETC/lib/python3.6/site-packages/django_filters/rest_framework/backends.py", line 30, in get_filter_class

filter_model = filter_class.Meta.model

AttributeError: type object 'Meta' has no attribute 'model'

39d42a8553ec40f65ebbec63402448b1.png

98959f433f0b52f813e7b46d918f0c13.png` """

Return the django-filters `FilterSet` used to filter the queryset.

"""

filter_class = getattr(view, 'filter_class', None)

filter_fields = getattr(view, 'filter_fields', None)

if filter_class:

filter_model = filter_class.Meta.model ...

assert issubclass(queryset.model, filter_model), \

'FilterSet model %s does not match queryset model %s' % \

(filter_model, queryset.model)

return filter_class

▶ Local vars`

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐