#27974: Degraded performance when rendereing ChoiceField with lots of options 
and
DEBUG=True
-------------------------------------+-------------------------------------
     Reporter:  karyon               |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Template system      |                  Version:  1.11
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Florian Apolloner):

 The main issue here is that the render context is per template rendering.
 I'd argue that the resolved templates should stay constant during one
 rendering cycle so this might be a somewhat sensible fix:
 {{{
 diff --git a/django/template/loader_tags.py
 b/django/template/loader_tags.py
 index d043e5eb52..6050b9f61f 100644
 --- a/django/template/loader_tags.py
 +++ b/django/template/loader_tags.py
 @@ -175,7 +175,7 @@ class IncludeNode(Node):
              if not callable(getattr(template, 'render', None)):
                  # If not, we'll try our cache, and get_template()
                  template_name = template
 -                cache =
 context.render_context.setdefault(self.context_key, {})
 +                cache =
 context.render_context.dicts[0].setdefault(self.context_key, {})
                  template = cache.get(template_name)
                  if template is None:
                      template =
 context.template.engine.get_template(template_name)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27974#comment:1>
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/064.5a624762638d097472e43a8a438c01b7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to