Opened 7 years ago

Closed 7 years ago

#9873 closed (duplicate)

Template reuse is worthless(when inheretiance or inclusion involved) because parent templates get re-compiled every time

Reported by: novoya Owned by: nobody
Component: Template system Version: master
Severity: Keywords: template cache
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The following view module fails to make good reuse to the template
For each new request, all inherited/included templates will be recreated and compiled

tpl = loader.get_template('mytemplate.html')

def view_func1(request):
     '''
        Any inherited templates from tpl
        will created and recompiled again and again
     '''
     return HttpResponse(tpl.render(context)) 

Attached a very simple patch to solve the problem:
1.Simple template caching in the django.template.loader
2.Minimum change in django.template.loader_tags

Attachments (1)

template_cache.diff (2.0 KB) - added by novoya 7 years ago.

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by novoya

comment:1 Changed 7 years ago by dc

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #9874

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