Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#19280 closed Cleanup/optimization (fixed)

Detect broken {% url %} syntax

Reported by: Anssi Kääriäinen Owned by: Tome Cvitan
Component: Template system Version: 1.5-alpha-1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In 1.5 the url syntax change will likely result in users getting this template error:

NoReverseMatch: Reverse for '' with arguments '()' and keyword arguments '{}' not found.

I think we could catch the error in the url tag, and check if we are trying to reverse . If so, add in a hint:

NoReverseMatch: Reverse for '' with arguments '()' and keyword arguments '{}' not found. Note: url syntax has changed in Django 1.5, see [insert good resource here]

This could save some time for those upgrading to Django 1.5.

Change History (9)

comment:1 by Tome Cvitan, 12 years ago

Owner: changed from nobody to Tome Cvitan

comment:2 by Tome Cvitan, 12 years ago

Has patch: set

comment:3 by Jannis Leidel, 12 years ago

Triage Stage: AcceptedReady for checkin
Type: UncategorizedCleanup/optimization

I guess we should capitalize "url" but other than that this looks good to me.

comment:4 by Aymeric Augustin, 12 years ago

Needs tests: set
Triage Stage: Ready for checkinAccepted

I'm going to add a test and commit this patch.

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

Resolution: fixed
Status: newclosed

In 8c2f36260e71acb41596004f6abc2ead4c917f6d:

[1.5.x] Fixed #19280 -- Raised an explicit exception for the old {% url %} syntax.

Backport of 6b8a7ce.

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

In d26691958443a4b968fecba5510c37768153fafa:

Fixed #19280 -- Raised an explicit exception for the old {% url %} syntax.

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

In 7644800070bf3027fb10cd45ea9f0e36e8334fc1:

Change exception type to reduce confusion.

TemplateSyntaxError is expected at compile time, not at run time.

Refs #19280.

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

In 37c54c27bdb555de8525fbb56681cf4448d0020c:

[1.5.x] Change exception type to reduce confusion.

TemplateSyntaxError is expected at compile time, not at run time.

Refs #19280.

Backport of 7644800.

comment:9 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