Opened 8 years ago

Closed 8 years ago

#20934 closed Bug (fixed)

NoReverseMatch on ModelAdmin.changelist_view if appname_modelname_change url is removed from get_urls

Reported by: Rainer Koirikivi Owned by: Rainer Koirikivi
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Accessing the changelist_view of a ModelAdmin subclass results in a NoReverseMatch error if get_urls is overridden so that the "appname_modelname_change" url is removed, but "appname_modelname_changelist" is left untouched.

Example ModelAdmin subclass causing this error:

class UnchangeableModelAdmin(admin.ModelAdmin):
    model = models.UnchangeableModel

    def get_urls(self):
        # return the standard urls, except for the change url
        urlpatterns0 = super(UnchangeableModelAdmin, self).get_urls()
        return [p for p in urlpatterns0 if not"_change")]

Traceback points to line 91 in django/contrib/admin/templates/admin/change_list.html, namely the result_list template tag.

Related issue: #20640

Change History (5)

comment:1 Changed 8 years ago by Rainer Koirikivi

Created a test project to verify this bug and #20640:

comment:2 Changed 8 years ago by Tim Graham

Component: Uncategorizedcontrib.admin
Triage Stage: UnreviewedAccepted

comment:3 Changed 8 years ago by Rainer Koirikivi

Owner: changed from nobody to Rainer Koirikivi
Status: newassigned

comment:4 Changed 8 years ago by Rainer Koirikivi

Has patch: set

Topic branch at
Pull request at

Tests pass under sqlite and postgresql

comment:5 Changed 8 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 65cf82bd08631a7aa8d9dd007b2527476fa3304f:

Fixed #20934 -- Avoided NoReverseMatch in ModelAdmin.changelist_view

The view tried to display links to a ModelAdmin's change_view, which
resulted in NoReverseMatches if get_urls was overridden to remove the
corresponding url.

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