Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#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 Aymeric Augustin, 12 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

We added a specific error message for Django 1.5. It'd be nice to make it work in as many circumstances as possible.

Version 0, edited 12 years ago by Aymeric Augustin (next)

comment:2 by Aymeric Augustin <aymeric.augustin@…>, 12 years ago

Resolution: fixed
Status: newclosed

In d6bad2e9ea77ce48ee5755a7b44682d892bfa3d4:

[1.5.x] Fixed #19392 -- Improved error for old-style url tags with dashes.

Thanks dloewenherz for the report.

Backport of 4951932 from master.

comment:3 by Aymeric Augustin <aymeric.augustin@…>, 12 years ago

In 49519328b4988bf89c11d50191cdee8e9bec3aaa:

Fixed #19392 -- Improved error for old-style url tags with dashes.

Thanks dloewenherz for the report.

comment:4 by Tim Graham <timograham@…>, 11 years ago

In 72b080c2c8a5ab7930b13688b2865ebc5b636687:

Removed Django 1.5 upgrade hints for {% url %} tag.

Refs #19280 and Refs #19392.

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