[Django] #21435: Improved error message for reverse v. reverse_lazy

22 views
Skip to first unread message

Django

unread,
Nov 13, 2013, 10:22:08 PM11/13/13
to django-...@googlegroups.com
#21435: Improved error message for reverse v. reverse_lazy
-------------------------------+--------------------
Reporter: elena | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
{{{
ImproperlyConfigured: The included urlconf %s doesn't have any patterns in
it.
}}}

Uninformative foremost as '''%s''' is top-level urls (problem usually in
included urls).

Caused by using '''reverse''' rather than '''reverse_lazy''' in some view.

No feedback whatsoever is given as to:
- that the error is caused in view rather than url
- which view this might be, or even which app it is in


'''Context:''' You get this error starting the developer server. The error
is cached (#11712) and fixing it doesn't make the error go away adding to
the confusion.[[BR]]
'''Suggestion:''' At least more specificity as to where the error lies.

Related tickets:

- https://code.djangoproject.com/ticket/17084
- https://code.djangoproject.com/ticket/15685
- https://code.djangoproject.com/ticket/11712


The above added here:
https://code.djangoproject.com/wiki/BetterErrorMessages


Appears be reproducible by adding to any view:

{{{
from django.core.urlresolvers import reverse

class DetailView(generic.DetailView):
...
attr = reverse('anything')
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21435>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 2, 2013, 9:48:21 AM12/2/13
to django-...@googlegroups.com
#21435: Improved error message for reverse v. reverse_lazy
-------------------------------+------------------------------------

Reporter: elena | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by aaugustin):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0


Comment:

Indeed, we could provide an error message hinting at the most likely cause
— a circular import.

--
Ticket URL: <https://code.djangoproject.com/ticket/21435#comment:1>

Django

unread,
Jan 27, 2014, 12:57:16 PM1/27/14
to django-...@googlegroups.com
#21435: Improved error message for reverse v. reverse_lazy
--------------------------------------+------------------------------------
Reporter: elena | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: 1.6

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by carljm):

* component: Uncategorized => Core (URLs)
* type: Uncategorized => Cleanup/optimization


--
Ticket URL: <https://code.djangoproject.com/ticket/21435#comment:2>

Django

unread,
Feb 22, 2014, 7:55:32 AM2/22/14
to django-...@googlegroups.com
#21435: Improved error message for reverse v. reverse_lazy
-------------------------------------+-------------------------------------
Reporter: elena | Owner: bpeschier
Type: | Status: assigned
Cleanup/optimization | Version: 1.6
Component: Core (URLs) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: nlsprint14 | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by bpeschier):

* keywords: => nlsprint14
* owner: nobody => bpeschier
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/21435#comment:3>

Django

unread,
Feb 22, 2014, 8:08:22 AM2/22/14
to django-...@googlegroups.com
#21435: Improved error message for reverse v. reverse_lazy
-------------------------------------+-------------------------------------
Reporter: elena | Owner: bpeschier
Type: | Status: assigned
Cleanup/optimization | Version: 1.6
Component: Core (URLs) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: nlsprint14 | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by bpeschier):

Tweaked the error message, PR on
https://github.com/django/django/pull/2343

--
Ticket URL: <https://code.djangoproject.com/ticket/21435#comment:4>

Django

unread,
Feb 22, 2014, 8:18:40 AM2/22/14
to django-...@googlegroups.com
#21435: Improved error message for reverse v. reverse_lazy
-------------------------------------+-------------------------------------
Reporter: elena | Owner: bpeschier
Type: | Status: assigned
Cleanup/optimization | Version: 1.6
Component: Core (URLs) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: nlsprint14 | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by bpeschier):

The error is tested in the test suite, so we'll need to update it.

--
Ticket URL: <https://code.djangoproject.com/ticket/21435#comment:5>

Django

unread,
Feb 22, 2014, 8:31:01 AM2/22/14
to django-...@googlegroups.com
#21435: Improved error message for reverse v. reverse_lazy
-------------------------------------+-------------------------------------
Reporter: elena | Owner: bpeschier
Type: | Status: assigned
Cleanup/optimization | Version: 1.6
Component: Core (URLs) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: nlsprint14 | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by bpeschier):

* has_patch: 0 => 1


Comment:

Updated the PR.

--
Ticket URL: <https://code.djangoproject.com/ticket/21435#comment:6>

Django

unread,
Feb 22, 2014, 8:39:25 AM2/22/14
to django-...@googlegroups.com
#21435: Improved error message for reverse v. reverse_lazy
-------------------------------------+-------------------------------------
Reporter: elena | Owner: bpeschier
Type: | Status: assigned
Cleanup/optimization | Version: 1.6
Component: Core (URLs) | Resolution:
Severity: Normal | Triage Stage: Ready for
Keywords: nlsprint14 | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by erikr):

* cc: eromijn@… (added)
* stage: Accepted => Ready for checkin


Comment:

This looks fine to me, and the tests succeed.

--
Ticket URL: <https://code.djangoproject.com/ticket/21435#comment:7>

Django

unread,
Feb 22, 2014, 9:40:18 AM2/22/14
to django-...@googlegroups.com
#21435: Improved error message for reverse v. reverse_lazy
-------------------------------------+-------------------------------------
Reporter: elena | Owner: bpeschier
Type: | Status: closed
Cleanup/optimization | Version: 1.6
Component: Core (URLs) | Resolution: fixed

Severity: Normal | Triage Stage: Ready for
Keywords: nlsprint14 | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Baptiste Mispelon <bmispelon@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"173aa5199737c60ab883a0469684e83c01604ce8"]:
{{{
#!CommitTicketReference repository=""
revision="173aa5199737c60ab883a0469684e83c01604ce8"
Fixed #21435 -- Improved error message when urlconf is empty.

The new error message now hints that the most likely issue
is a circular import.

Thanks to trac user elena for the report and to
bpeschier for the original patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21435#comment:8>

Reply all
Reply to author
Forward
0 new messages