#21741: render_to_string without providing a dictionary still puts a dictionary
into the context
-----------------------------------------+--------------------
     Reporter:  Keryn Knight <django@…>  |      Owner:  nobody
         Type:  Cleanup/optimization     |     Status:  new
    Component:  Template system          |    Version:  master
     Severity:  Normal                   |   Keywords:
 Triage Stage:  Unreviewed               |  Has patch:  0
Easy pickings:  0                        |      UI/UX:  0
-----------------------------------------+--------------------
 given the following scenario:
 {{{
 >>> from django.template.loader import render_to_string
 >>> from django.template import Context
 >>> render_to_string('file.extension', context_instance=Context())
 >>> # or ...
 >>> render_to_string('file.extension')
 }}}
 where a dictionary is explicitly not being provided, the final context
 given to the template when `render()` is called will have `{}` as the last
 of the `.dicts`

 The reason is because if
 
[https://github.com/django/django/blob/fe995e6cbdcf2766cf0aa951c8ef4549ad27694c/django/template/loader.py#L167
 none is provided], a new dict is created, and then it is provided to the
 context instance
 
([https://github.com/django/django/blob/fe995e6cbdcf2766cf0aa951c8ef4549ad27694c/django/template/loader.py#L173
 1],
 
[https://github.com/django/django/blob/fe995e6cbdcf2766cf0aa951c8ef4549ad27694c/django/template/loader.py#L176
 2]) without checking the dict's `len()`

 Marking as cleanup/optimization because it doesn't cause any problems (the
 only one being: it appears in debug_toolbar), but providing the ticket at
 least means the option is there to change it, and a history of why not to
 change it exists if ''wontfix'd'' (which may be the best course of action,
 on balance, but that's not for me to say)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21741>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/080.6f4a39079727a6b1b246e2980acdf134%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to