#13672: template cache tag should gracefully handle uninitialized variables
----------------------------+-----------------------------------------------
 Reporter:  nbv4            |       Owner:  nobody    
   Status:  new             |   Milestone:            
Component:  Uncategorized   |     Version:  SVN       
 Keywords:  template cache  |       Stage:  Unreviewed
Has_patch:  0               |  
----------------------------+-----------------------------------------------
 I keep running into this problem. I have a page that uses the template
 cache tag. One of the variables that gets used as a cache key is sometimes
 available in the context, sometimes not (it's added to the context via
 middleware).

 If the variable is not initialized, the whole page fails to render. EX:

 --------
 context:

 {key1: 'value', key2: 'another value'}

 --------
 template:

 {% if key3 %}
 no errors are thrown here
 {% endif %}

 {% cache 1800 mycache key1 key2 key3 %}
 causes a problem
 {% endcache %}

 --------
 result:

 Caught VariableDoesNotExist while rendering: Failed lookup for key [key3]
 in u"[{'key1: 'value', key2: 'another value'}]"

 I think it would be best to just have the key be "None" if it's
 uninitialized instead of throwing an error.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13672>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to