#24338: {%extends%}-ing a file-based template object is broken by deprecation 
path
indirection
---------------------------------+--------------------------------------
     Reporter:  spectras         |                    Owner:  nobody
         Type:  Uncategorized    |                   Status:  new
    Component:  Template system  |                  Version:  1.8alpha1
     Severity:  Normal           |               Resolution:
     Keywords:  template         |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------

Comment (by spectras):

 You are right, it is covered in the documentation. The culprit code,
 however, lies in Django itself, as the '''{% extends %}''' tag has not
 been updated: it does not support the new backend-agnostic template
 objects and still expects a '''django.template.Template'''. However, there
 is no supported way to get one before the rendering stage.

 According to the '''{% extends %}''' documentation, this should work:
 {{{!#python
 from django.views.generic.base import TemplateView
 from django.template.loader import get_template

 class MyView(TemplateView):
     template_name = "mytemplate.html"
     def get_context_data(self, **kwargs):
         kwargs['parent_template'] = get_template('parent.html')
         return super(MyView, self).get_context_data(**kwargs)
 }}}
 {{{
 {# mytemplate.html #}
 {% extends parent_template %}
 }}}

 I guess there are two options:
 1) clearly mark in the documentation that '''{% extends %}''' is
 incompatible with '''get_template'''
 or
 2) update '''{% extends %}''' so it handles agnostic templates correctly.

--
Ticket URL: <https://code.djangoproject.com/ticket/24338#comment:2>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.a2843fed44788ec7da645704a9815562%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to