1

在我的项目中安装 Django Oscar 模块时出现错误,它给了我这个错误

from oscar import get_core_apps
ImportError: cannot import name 'get_core_apps'

这是我的 settings.py 文件...

from oscar import get_core_apps
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'compressor',
'widget_tweaks',
'south',
] + get_core_apps()

这是我在终端上得到的错误代码...

    self._databases = settings.DATABASES
 File "/home/amit/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
self._setup(name)
File "/home/amit/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
self._wrapped = Settings(settings_module)
File "/home/amit/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/amit/Desktop/Django/frobshop/frobshop/settings.py", line 32, in <module>
from oscar import get_core_apps
ImportError: cannot import name 'get_core_apps'
4

2 回答 2

2

get_core_apps以来已删除,如发行说明中所述:

已删除oscar.get_core_apps。现在通过将INSTALLED_APPS设置中的 Oscar 应用程序条目替换为分叉应用程序的条目来覆盖应用程序。

因此,您应该删除, 并改为get_core_apps更改。INSTALLED_APPS例如:

INSTALLED_APPS = [
    # Django apps
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.flatpages',

    # oscar apps
    'oscar',

    # your apps
    # ...
]
于 2019-08-02T08:28:14.940 回答
0

看起来“get_core_apps”不再存在。

来源: https ://github.com/django-oscar/django-oscar/pull/2633

于 2019-08-02T08:28:20.553 回答