#32377: Django duplicating block.super content
-----------------------------------------+------------------------
               Reporter:  jmarshall9120  |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  3.1
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 using in template inheritance as in the docs
 [https://docs.djangoproject.com/en/3.1/howto/overriding-templates
 /#extending-an-overridden-template, here] I'm getting duplication as
 shown:

 [[Image(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.

 [https://github.com/django-oscar/django-
 oscar/blob/master/src/oscar/templates/oscar/base.html 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
 [https://stackoverflow.com/questions/65819831/django-duplicating-block-
 super-content/65823247 here]

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32377>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/056.5243186e900d8dccccc1fb29856072dc%40djangoproject.com.

Reply via email to