Opened 13 years ago

Closed 13 years ago

#15070 closed Bug (fixed)

url tag does not work within inclusion_tags when current_app is needed

Reported by: raony araújo Owned by: Gary Reynolds
Component: Template system Version: dev
Severity: Normal Keywords: easy-pickings
Cc: botondus@…, gary@…, jleidel@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

suppose we deployed the same app two times (e.g., django-admin), each include in urls.py has tha namespace and app_name set.

now we create a custom tag (with the inclusion_tag function of Library) that renders a specific template which has an url tag trying to resolve an url from the mentioned app.

then we create a view which set current_app on the RequestContext object and renders a template with the custom tag; the reverse inside the url_tag at the included template fails to resolve to the right app as if the current_app was not set.

Attachments (4)

15070.diff (790 bytes ) - added by raony araújo 13 years ago.
15070_with_tests.patch (2.7 KB ) - added by Béres Botond 13 years ago.
15070.2.diff (2.8 KB ) - added by Matthias Kestenholz 13 years ago.
15070_goodtune.diff (3.9 KB ) - added by Gary Reynolds 13 years ago.

Download all attachments as: .zip

Change History (15)

by raony araújo, 13 years ago

Attachment: 15070.diff added

comment:1 by Łukasz Rekucki, 13 years ago

Keywords: easy-pickings added
Needs tests: set
Triage Stage: UnreviewedAccepted

A regression test is also required. tests/regressiontests/templates/custom.py is most likely the right place.

comment:2 by Béres Botond, 13 years ago

Owner: changed from nobody to Béres Botond

by Béres Botond, 13 years ago

Attachment: 15070_with_tests.patch added

comment:3 by Béres Botond, 13 years ago

Cc: botondus@… added
Needs tests: unset
Status: newassigned

comment:4 by Matthias Kestenholz, 13 years ago

Refreshed patch for current SVN trunk.

Only change: Made sure it applies correctly and added strip() calls so that the trailing newline in the newly added template does not cause test failures.

by Matthias Kestenholz, 13 years ago

Attachment: 15070.2.diff added

comment:5 by Gary Reynolds, 13 years ago

Cc: gary@… added
Patch needs improvement: set
Severity: Normal
Type: Uncategorized

I encountered this myself just recently and had started working on my own patch.

When fixing this we should also provide coverage for the use_l10n attribute as well.

comment:6 by James Addison, 13 years ago

Type: UncategorizedBug

by Gary Reynolds, 13 years ago

Attachment: 15070_goodtune.diff added

comment:7 by Gary Reynolds, 13 years ago

Owner: changed from Béres Botond to Gary Reynolds
Patch needs improvement: unset
Status: assignednew

I've added a new patch in attachment:15070_goodtune.diff which also deals with the use_l10n case I mentioned in comment:5.

The tests follow the same convention to the previous suggestions. If there is a better approach for writing tests for inclusion tags then please let me know and I'll review.

comment:8 by Jacob, 13 years ago

Easy pickings: set

comment:9 by Jannis Leidel, 13 years ago

Triage Stage: AcceptedReady for checkin

comment:10 by Jannis Leidel, 13 years ago

Cc: jleidel@… added

comment:11 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

In [16117]:

Fixed #15070 -- Also pass current_app and use_l10n in inclusion_tags. Thanks, raony, mk and goodtune.

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