Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#8177 closed (fixed)

reverse() should report the reverse lookup that fails.

Reported by: mrts Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: reverse
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Now that {% url foo %} does not fail silently any more, it's really important to report which reverse lookup failed.

Compare:

Before the attached patch:
--------------------------
Django version 1.0-alpha_2-SVN-8255, using settings 'trunk.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
...
  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 291, in reverse
    raise NoReverseMatch
NoReverseMatch

After the attached patch:
--------------------------
Django version 1.0-alpha_2-SVN-8255, using settings 'trunk.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
...
  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 291, in reverse
    raise NoReverseMatch("Reverse for '%s' not found." % lookup_view)

NoReverseMatch: Reverse for 'foo-bar' not found.

Run a rgrep foo-bar . and you find the offending place easily.

Attachments (1)

verbose_noreversematch.diff (846 bytes) - added by mrts 6 years ago.

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by mrts

comment:1 Changed 6 years ago by julien

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

+1 on this! How strange, I was just about to file the same ticket with pretty much the same patch :)

comment:2 Changed 6 years ago by mrts

Not strange at all, people will be hit by this all over Djangoland now that r8211 is in and there will be loud cries of "Help! I don't know which of my url tags is failing!" everywhere :).

I think that r8211 was a right thing though, I was able to catch an empty {% url %} I'd missed previously (but not before patching Django).

comment:3 Changed 6 years ago by lukeplant

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

Fixed in [8272]

comment:4 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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.