Opened 12 years ago
Closed 12 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 |
Description
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 p.name.endswith("_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 by , 12 years ago
comment:2 by , 12 years ago
| Component: | Uncategorized → contrib.admin |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:3 by , 12 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:4 by , 12 years ago
| Has patch: | set |
|---|
Topic branch at https://github.com/koirikivi/django/tree/ticket_20934
Pull request at https://github.com/django/django/pull/1499
Tests pass under sqlite and postgresql
comment:5 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Created a test project to verify this bug and #20640: https://github.com/koirikivi/django-admin-views-test