Django Oscar模板覆盖无效

时间:2019-11-20 09:18:24

标签: django-oscar

我正面临django oscar模板覆盖问题。我正在使用Oscar 2.0.3和Django 2.2.7

我正在使用文档中提到的method-1。我的项目结构看起来像

myproject
   cache
   catalogue (I have overridden this app)
   categories 
   images
   templates
      base.html
   myproject
   manage.py

我将TEMPLATES编辑为


import os
location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', x)

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [location('templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'oscar.apps.search.context_processors.search_form',
                'oscar.apps.checkout.context_processors.checkout',
                'oscar.apps.customer.notifications.context_processors.notifications',
                'oscar.core.context_processors.metadata',
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages', 
            ],
        },
    },
]

我正在base.html中进行更改,但不会在127.0.0.1:8000/catalogue/上进行复制(127.0.0.1:8000重定向到此URL)

感谢您的帮助!谢谢!

1 个答案:

答案 0 :(得分:1)

您正在使用的教程适用于旧版的Oscar(1.6)。

在Oscar 2.0中,模板结构已更改。具体来说,base.html现在位于oscar/base.html。这意味着要覆盖它,您必须在templates/oscar/base.html而不是templates/base.html处创建一个文件。

其他所有Oscar模板也是如此。