Opened 3 years ago

Closed 3 years ago

Last modified 18 months ago

#19280 closed Cleanup/optimization (fixed)

Detect broken {% url %} syntax

Reported by: akaariai Owned by: tome
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 Changed 3 years ago by tome

  • Owner changed from nobody to tome

comment:2 Changed 3 years ago by tome

  • Has patch set

comment:3 Changed 3 years ago by jezdez

  • Triage Stage changed from Accepted to Ready for checkin
  • Type changed from Uncategorized to Cleanup/optimization

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

comment:4 Changed 3 years ago by aaugustin

  • Needs tests set
  • Triage Stage changed from Ready for checkin to Accepted

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

comment:5 Changed 3 years ago by Aymeric Augustin <aymeric.augustin@…>

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

In 8c2f36260e71acb41596004f6abc2ead4c917f6d:

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

Backport of 6b8a7ce.

comment:6 Changed 3 years ago by Aymeric Augustin <aymeric.augustin@…>

In d26691958443a4b968fecba5510c37768153fafa:

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

comment:7 Changed 3 years ago by Aymeric Augustin <aymeric.augustin@…>

In 7644800070bf3027fb10cd45ea9f0e36e8334fc1:

Change exception type to reduce confusion.

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

Refs #19280.

comment:8 Changed 3 years ago by Aymeric Augustin <aymeric.augustin@…>

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 Changed 18 months 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