Opened 15 years ago
Closed 15 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)
Change History (15)
by , 15 years ago
| Attachment: | 15070.diff added |
|---|
comment:1 by , 15 years ago
| Keywords: | easy-pickings added |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 15 years ago
| Owner: | changed from to |
|---|
by , 15 years ago
| Attachment: | 15070_with_tests.patch added |
|---|
comment:3 by , 15 years ago
| Cc: | added |
|---|---|
| Needs tests: | unset |
| Status: | new → assigned |
comment:4 by , 15 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 , 15 years ago
| Attachment: | 15070.2.diff added |
|---|
comment:5 by , 15 years ago
| Cc: | 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 , 15 years ago
| Type: | Uncategorized → Bug |
|---|
by , 15 years ago
| Attachment: | 15070_goodtune.diff added |
|---|
comment:7 by , 15 years ago
| Owner: | changed from to |
|---|---|
| Patch needs improvement: | unset |
| Status: | assigned → 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 by , 15 years ago
| Easy pickings: | set |
|---|
comment:9 by , 15 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:10 by , 15 years ago
| Cc: | added |
|---|
A regression test is also required.
tests/regressiontests/templates/custom.pyis most likely the right place.