我一直在尝试安装 django-oscar,但是当我尝试进行迁移时(通过:python manage.py migrate
),它给了我这个错误。
ImportError: cannot import name 'OSCAR_MAIN_TEMPLATE_DIR' from 'oscar' (C:\Users\dell\Envs\eshop\lib\site-packages\oscar__init__.py)
我正在使用的代码:
from oscar import OSCAR_MAIN_TEMPLATE_DIR
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates'),
OSCAR_MAIN_TEMPLATE_DIR
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.i18n',
'django.contrib.messages.context_processors.messages',
'oscar.apps.search.context_processors.search_form',
'oscar.apps.promotions.context_processors.promotions',
'oscar.apps.checkout.context_processors.checkout',
'oscar.apps.customer.notifications.context_processors.notifications',
'oscar.core.context_processors.metadata',
],
},
},
]
最佳答案
来自release notes对于2.0+(2019-07-04):
OSCAR_MAIN_TEMPLATE_DIR
setting has been removed and existing templates updated with the full path. See issue:1378
, issue:2250
. Please update your templates accordingly.
关于python - 导入错误: cannot import name 'OSCAR_MAIN_TEMPLATE_DIR' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57642847/