Opened 5 years ago

Closed 5 years ago

#21435 closed Cleanup/optimization (fixed)

Improved error message for reverse v. reverse_lazy

Reported by: Elena Williams Owned by: Bas Peschier
Component: Core (URLs) Version: 1.6
Severity: Normal Keywords: nlsprint14
Cc: eromijn@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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.
Suggestion: At least more specificity as to where the error lies.

Related tickets:

The above added here:

Appears be reproducible by adding to any view:

from django.core.urlresolvers import reverse
class DetailView(generic.DetailView):
    attr = reverse('anything')

Change History (8)

comment:1 Changed 5 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

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

comment:2 Changed 5 years ago by Carl Meyer

Component: UncategorizedCore (URLs)
Type: UncategorizedCleanup/optimization

comment:3 Changed 5 years ago by Bas Peschier

Keywords: nlsprint14 added
Owner: changed from nobody to Bas Peschier
Status: newassigned

comment:4 Changed 5 years ago by Bas Peschier

Tweaked the error message, PR on

comment:5 Changed 5 years ago by Bas Peschier

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

comment:6 Changed 5 years ago by Bas Peschier

Has patch: set

Updated the PR.

comment:7 Changed 5 years ago by Sasha Romijn

Cc: eromijn@… added
Triage Stage: AcceptedReady for checkin

This looks fine to me, and the tests succeed.

comment:8 Changed 5 years ago by Baptiste Mispelon <bmispelon@…>

Resolution: fixed
Status: assignedclosed

In 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.

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