Code

Opened 20 months ago

Closed 19 months ago

Last modified 4 months 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

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.

Attachments (0)

Change History (4)

comment:1 Changed 19 months 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 19 months ago by aaugustin (previous) (diff)

comment:2 Changed 19 months 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 19 months 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 4 months ago by Tim Graham <timograham@…>

In 72b080c2c8a5ab7930b13688b2865ebc5b636687:

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

Refs #19280 and Refs #19392.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.