Opened 12 years ago

Closed 12 years ago

#17333 closed Bug (fixed)

Errors when reversing admin URLs when custom ModelAdmin doesn't provide model add/change URLs

Reported by: Ramiro Morales Owned by: nobody
Component: contrib.admin Version: dev
Severity: Release blocker 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

(Originally reported here)

Commit r16857 introduced a backward incompatible behavior of the admin app's master index and per-app index views.

The commit introduces changes in the template context building process that assume add and change permissions on models are always present when it is going to check for them. This fails with projects where these permissions might have been completely removed.

Attachments (2)

17333-wip-regression-tests.diff (3.7 KB ) - added by Ramiro Morales 12 years ago.
17333-1.diff (8.5 KB ) - added by Ramiro Morales 12 years ago.
Avoid NoRevereMatch when a custom ModelAdmin.get_urls() doesn't call super()

Download all attachments as: .zip

Change History (10)

comment:1 by Ramiro Morales, 12 years ago

Type: UncategorizedBug

comment:2 by Jannis Leidel, 12 years ago

Severity: NormalRelease blocker

comment:3 by Ramiro Morales, 12 years ago

Resolution: worksforme
Status: newclosed

Actually, I can't reproduce this, i.e. cant create a regression test.

Things tried:

  • Removing the add Permission mode instance completely associated with a given model
  • Returning False from the model's ModelAdmin has_add_permission() and
  • Explicitly not granting the needed permission to the test user

And no NoReverseMatch exception gets triggered as originally reported here. I'm attaching the WIP patch for the tests and closing this worksforme.

I'm not going to change anything until we can reproduce the failing condition. It would be great if user kingtut that posted that comment can give us additional feedback, bonus points if he can modify the test case to fail.

Last edited 12 years ago by Ramiro Morales (previous) (diff)

by Ramiro Morales, 12 years ago

comment:4 by Jannis Leidel, 12 years ago

With regard to the original bug report, there is a fix out there, at least for django-mailchimp: https://github.com/JohnRandom/django-mailchimp/commit/a8bfef1581ce43a2ea6f56a3707f14a611596148

comment:5 by Ramiro Morales, 12 years ago

Resolution: worksforme
Status: closedreopened

by Ramiro Morales, 12 years ago

Attachment: 17333-1.diff added

Avoid NoRevereMatch when a custom ModelAdmin.get_urls() doesn't call super()

comment:6 by Ramiro Morales, 12 years ago

Has patch: set

comment:7 by Ramiro Morales, 12 years ago

Summary: Errors when reversing admin URLs when add/change standard permissions don't existErrors when reversing admin URLs when custom ModelAdmin doesn't provide model add/change URLs

comment:8 by Ramiro Morales, 12 years ago

Resolution: fixed
Status: reopenedclosed

In [17237]:

Stopped unconditionally reversing admin model add/change URLs.

Starting with [16857] this could cause HTTP 500 errors when
ModelAdmin.get_urls() has been customized to the point it doesn't
provide these standard URLs.

Fixes #17333. Refs #15294.

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