Code

Opened 4 years ago

Closed 4 years ago

#12348 closed (duplicate)

ForeignKeyRawIdWidget doesn't catch ObjectDoesNotExist when raw_id is illegal

Reported by: jay Owned by: nobody
Component: contrib.admin Version: 1.1
Severity: Keywords: ForeignKeyRawIdWidget
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If a FK is referred raw_id_fields ModelAdmin, it will use ModelChoiceField with ForeignKeyRawIdWidget to render itself.

ForeignKeyRawIdWidget tests whether the value passed in the render() method is null to see if it has to call label_for_value to show the repr of the referred record. So if the value is faulty but not null, label_for_value will still be called, then ObjectDostNotExist will be thrown without any handling.

Attachments (1)

widgets.py.diff (608 bytes) - added by jay 4 years ago.

Download all attachments as: .zip

Change History (2)

Changed 4 years ago by jay

comment:1 Changed 4 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #11465 that has an identical patch.

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.