Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#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 Tim Graham, 10 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

Could you please add a test and send a pull request? You may find the patch review checklist helpful.

comment:2 by David Winterbottom, 10 years ago

Owner: changed from nobody to David Winterbottom
Status: newassigned

comment:3 by David Winterbottom, 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 David Winterbottom, 10 years ago

Resolution: worksforme
Status: assignedclosed

comment:5 by David Winterbottom, 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 Tim Graham, 10 years ago

Resolution: worksformeinvalid

Yes, the OP closed his PR has invalid, but forgot to close this ticket.

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