Opened 5 years ago
Closed 5 years ago
#15070 closed Bug (fixed)
url tag does not work within inclusion_tags when current_app is needed
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)
Change History (15)
Changed 5 years ago by raony
comment:1 Changed 5 years ago by lrekucki
- Keywords easy-pickings added
- Needs documentation unset
- Needs tests set
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:2 Changed 5 years ago by bberes
- Owner changed from nobody to bberes
Changed 5 years ago by bberes
comment:3 Changed 5 years ago by bberes
- Cc botondus@… added
- Needs tests unset
- Status changed from new to assigned
comment:4 Changed 5 years ago by mk
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.
Changed 5 years ago by mk
comment:5 Changed 5 years ago by goodtune
- Cc gary@… added
- Patch needs improvement set
- Severity set to Normal
- Type set to 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 Changed 5 years ago by jaddison
- Type changed from Uncategorized to Bug
Changed 5 years ago by goodtune
comment:7 Changed 5 years ago by goodtune
- Owner changed from bberes to goodtune
- Patch needs improvement unset
- Status changed from assigned to new
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 Changed 5 years ago by jacob
- Easy pickings set
comment:9 Changed 5 years ago by jezdez
- Triage Stage changed from Accepted to Ready for checkin
comment:10 Changed 5 years ago by jezdez
- Cc jleidel@… added
comment:11 Changed 5 years ago by jezdez
- Resolution set to fixed
- Status changed from new to closed
A regression test is also required. tests/regressiontests/templates/custom.py is most likely the right place.