Code

Opened 2 years ago

Closed 2 years ago

#17333 closed Bug (fixed)

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

Reported by: ramiro Owned by: nobody
Component: contrib.admin Version: master
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 2 years ago.
17333-1.diff (8.5 KB) - added by ramiro 2 years ago.
Avoid NoRevereMatch when a custom ModelAdmin.get_urls() doesn't call super()

Download all attachments as: .zip

Change History (10)

comment:1 Changed 2 years ago by ramiro

  • Type changed from Uncategorized to Bug

comment:2 Changed 2 years ago by jezdez

  • Severity changed from Normal to Release blocker

comment:3 Changed 2 years ago by ramiro

  • Resolution set to worksforme
  • Status changed from new to closed

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 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 the user kingtut that posted that comment can give us additional feedback, bonus points if he can modify the test case to fail.

Version 0, edited 2 years ago by ramiro (next)

Changed 2 years ago by ramiro

comment:4 Changed 2 years ago by jezdez

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 Changed 2 years ago by ramiro

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Changed 2 years ago by ramiro

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

comment:6 Changed 2 years ago by ramiro

  • Has patch set

comment:7 Changed 2 years ago by ramiro

  • Summary changed from Errors when reversing admin URLs when add/change standard permissions don't exist to Errors when reversing admin URLs when custom ModelAdmin doesn't provide model add/change URLs

comment:8 Changed 2 years ago by ramiro

  • Resolution set to fixed
  • Status changed from reopened to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.