python - 导入错误: cannot import name 'OSCAR_MAIN_TEMPLATE_DIR'

标签 python django django-oscar

我一直在尝试安装 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/

相关文章:

python - 从子进程执行 curl 的正确方法是什么?

Python 设置查找效率

python - 如何在 Django 测试设置中创建包含用户的记录

python - 如何定义sklearn.cluster.DBSCAN的eps参数的值范围?

python - Python 中的并行处理选项

python - 为django中的组分配权限

python - Django Rest 框架路由器 url 为空

python - django oscar 和 djangoccms

django - Django Oscar 的商店信用/虚拟货币应用程序?

Django-oscar 产品图片错误