Opened 4 years ago

Closed 4 years ago

#12599 closed (invalid)

MultiValueDictKeyError with inline admin, when inline model's ID not displayed

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


An odd issue, which I don't have the Python-fu to debug fully.

I have a meta-model called 'Person' (they're parliamentarians, not that this matters especially) to which expenses and past Ministerial Offices are attached through an AdminInline interface. If I do not remove line 6 from the file attached ("exclude = ('moffice_id',)") then I can't save anything on the page because a traceback like the one attached here results. Yay, workaround available, but boo - exposing nasty IDs in editable fields where I don't want them.

I don't know whether the fact that the model Moffice does not use the default ID fieldname is a factor here or not.

Attaching a minimal and and the traceback generated when the admin barfs.

Attachments (3) (584 bytes) - added by handelaar 4 years ago. (1.8 KB) - added by handelaar 4 years ago.
traceback.txt (9.0 KB) - added by handelaar 4 years ago.

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by handelaar

Changed 4 years ago by handelaar

Changed 4 years ago by handelaar

comment:1 Changed 4 years ago by kmtracey

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

If you don't want the primary key field to be displayed and editable then it needs to be made an AutoField, not an IntegerField. Otherwise how else can it be assigned? I think the problem here is you have models asking for the impossible: non-displayed, non-editable, and non-auto-assigned primary keys in the inlines. I'm pretty sure simply making the primary key field an AutoField will fix the problem. Do not manually exclude the field, the admin will correctly handle hiding the field from the user if it is defined properly.

Last edited 3 years ago by kmtracey (previous) (diff)

Add Comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.