Opened 10 years ago

Closed 10 years ago

Last modified 7 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 10 years ago.

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by mrts

Attachment: verbose_noreversematch.diff added

comment:1 Changed 10 years ago by Julien Phalip

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 Changed 10 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 10 years ago by Luke Plant

Resolution: fixed
Status: newclosed

Fixed in [8272]

comment:4 Changed 7 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

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