Opened 4 years ago

Closed 4 years ago

Last modified 2 years ago

#19392 closed Cleanup/optimization (fixed)

Old-style url names (with dashes) throw confusing template traceback

Reported by: dloewenherz 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


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/ 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 Changed 4 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Cleanup/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.

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.

Last edited 4 years ago by aaugustin (previous) (diff)

comment:2 Changed 4 years ago by Aymeric Augustin <aymeric.augustin@…>

  • Resolution set to fixed
  • Status changed from new to closed

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 Changed 4 years ago by Aymeric Augustin <aymeric.augustin@…>

In 49519328b4988bf89c11d50191cdee8e9bec3aaa:

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

Thanks dloewenherz for the report.

comment:4 Changed 2 years ago by Tim Graham <timograham@…>

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