Search code examples
djangodjango-oscar

Why I can't customize templates in Django-Oscar?


I'm trying to customize the base template by following the documentation. But the template doesn't respond to my changes in any way... What am I doing wrong?

My template's path from location():

.../django_shop/frobshop/frobshop/templates

My structure of project:

enter image description here

My settings:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            location('templates')
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.request',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.contrib.messages.context_processors.messages',

                # Oscar specific

                'oscar.apps.search.context_processors.search_form',
                'oscar.apps.communication.notifications.context_processors.notifications',
                'oscar.apps.checkout.context_processors.checkout',
                'oscar.core.context_processors.metadata',
            ],
            'debug': DEBUG,
        }
    }
]

My base.html:

{% extends 'oscar/base.html' %}

{% load i18n %}

{% block title %}
{% trans 'test title' %}
{% endblock %}
test

Solution

  • Your base.html is in the wrong location - it needs to be in frobshop/templates/oscar/base.html instead of of frobshop/templates/base.html.

    All of Oscar's templates are namespaced with the oscar/ prefix - so to override them you have to do the same.