#24516 closed Bug (invalid)
make_template_fragment_key behaves differently than the {% cache %} template tag for the "None" value
Reported by: | Antonin | Owned by: | David Winterbottom |
---|---|---|---|
Component: | Core (Cache system) | Version: | 1.7 |
Severity: | Normal | Keywords: | cache, templatetag |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The function make_template_fragment_key in django.core.cache.utils can be used to compute the cache key associated with a given template fragment.
When one of the parameters of this cache fragment get the value None, this function translates internally this value to 'None' (the string), whereas the template tag translates it to the empty string.
A patch for this bug can be found on the following branch:
http://github.com/wetneb/django
Change History (6)
comment:1 by , 10 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 10 years ago
I can't recreate this sorry - I find that None
gets passed to the make_template_fragment_key
function when called from the template tag. Here's the snippet I used to test:
from django.template import Context,Template t = Template( "{% load cache %}{% cache 300 test myvar %}hello{% endcache %}") t.render(Context({'myvar': None}))
What am I missing?
comment:4 by , 10 years ago
Resolution: | → worksforme |
---|---|
Status: | assigned → closed |
comment:5 by , 10 years ago
Have resolved for now but am happy to revisit if you can provide some info on how to recreate the issue.
comment:6 by , 10 years ago
Resolution: | worksforme → invalid |
---|
Yes, the OP closed his PR has invalid, but forgot to close this ticket.
Could you please add a test and send a pull request? You may find the patch review checklist helpful.