Opened 4 years ago

Closed 4 years ago

#32377 closed Uncategorized (invalid)

Django duplicating block.super content

Reported by: jmarshall9120 Owned by: nobody
Component: Uncategorized Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

using in template inheritance as in the docs here I'm getting duplication as shown:

https://i.stack.imgur.com/UiKiv.png

In the above photo the commented Google Tag Manager text has been duplicated. Obviously I would like to put the actual tag manager in there, but it's a simpler example this way. Anything I put in my child template tag is duplicated when I call {{ base.super }} I'm using Oscar, so here's my inheritance scheme.

oscar/base.html

#from oscar module
#relevent sections only
    
{% load i18n %}
{% load static %}
<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE|default:"en-gb" }}" class="{% block html_class %}no-js{% endblock %}">
    <head>
        {% block tracking %}
            {# Default to using Google analytics #}
            {% include "oscar/partials/google_analytics.html" %}
       {% endblock %}
    </head>

my base override

# located in my procject at 'oscar/base.html'
{% extends 'oscar/base.html' %}
    
{% block tracking %}
    {{ block.super }}
    <!-- Google Tag Manager -->
    <!-- End Google Tag Manager -->
{% endblock %}

Below is anything else I think could be involved. Any troubleshooting tips that would help me debug this would be welcome.

my view

from django.http import HttpResponse
from django.views.generic.base import TemplateView
    
class BaseTestView(TemplateView):
    template_name = "oscar/base.html"

urls.py

from myurls import BaseTestView
urlpatterns = [
    path('i18n/', include('django.conf.urls.i18n')),
    path('admin/', admin.site.urls),
        
    path('base_test', BaseTestView.as_view(), name='base+test'), 
 
##OSCAR###############################################################
    path('', include(apps.get_app_config('oscar').urls[0])),
 ##WAGTAIL#############################################################
    path('cms/', include(wagtailadmin_urls)),
    path('documents/', include(wagtaildocs_urls)),
    path('pages/', include(wagtail_urls)),        
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \
    + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

settings.py templates

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

There is a copy of this ticket on SO here

Change History (1)

comment:1 by Tim Graham, 4 years ago

Resolution: invalid
Status: newclosed

Please see TicketClosingReasons/UseSupportChannels for ways to get help.

Note: See TracTickets for help on using tickets.
Back to Top