#19392 closed Cleanup/optimization (fixed)
Old-style url names (with dashes) throw confusing template traceback
Reported by: | Dan Loewenherz | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.5-beta-1 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When migrating an existing project to Django 1.5 (one that has dashes in the URL names), I get a very confusing error in the template traceback. Namely:
TemplateSyntaxError at / Could not parse the remainder: '-login' from 'account-login'
<li><a href='{% url account-login %}'>Create Account</a></li>
The culprit is in the filter_raw_string
regex in django/template/base.py. When I change 'var_chars' to "-\w\."
(instead of "\w\."
, I get a more sensible error message:
NoReverseMatch at / 'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs.
I think the messaging here could be improved.
Change History (4)
comment:1 by , 12 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
We added a specific error message for Django 1.5. It'd be nice to make it work in as many circumstances as possible.
Changing
var_chars
has lots of consequences; it sounds excessive when the problem is just an unfriendly error message for people who don't read the release notes.