Code

#19951 closed Bug (fixed)

Avoid ValueError in admin when passing a string as PK for an inherited model with an integer PK field

Reported by: anonymous Owned by: ikks
Component: contrib.admin Version: master
Severity: Normal Keywords: admin inheritance integer PK
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In the admin if the PK for an inherited model is passed an string an error 500 is raised, the resulting status_code should be 404, the Exception throws a ValueError.

For example if in the tests the SuperVillain class is tried to be accessed with a wrong PK, like abc, the status_code is 500 and it should be 404.

Attachments (0)

Change History (3)

comment:1 Changed 17 months ago by ikks

  • Easy pickings set
  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to ikks
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:3 Changed 16 months ago by Ramiro Morales <cramm0@…>

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

In e2ee02c5bd412a6a1b33353cac1a222be989d71f:

Fixed #19951 -- Admin: Invalid model PK values shouldn't cause 500 status.

Avoid ValueError in admin when passing a string as PK for an inherited
model with an integer PK field.

Thanks ikks for the patch. See also #11191.

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.