Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#8177 closed (fixed)

reverse() should report the reverse lookup that fails.

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

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 16 years ago.

Download all attachments as: .zip

Change History (5)

by mrts, 16 years ago

Attachment: verbose_noreversematch.diff added

comment:1 by Julien Phalip, 16 years ago

Triage Stage: UnreviewedAccepted

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

comment:2 by mrts, 16 years ago

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 by Luke Plant, 16 years ago

Resolution: fixed
Status: newclosed

Fixed in [8272]

comment:4 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top