[Django] #12599: MultiValueDictKeyError with inline admin, when inline model's ID not displayed

17 views
Skip to first unread message

Django

unread,
Jan 13, 2010, 4:19:31 AM1/13/10
to djang...@holovaty.com, django-...@googlegroups.com
#12599: MultiValueDictKeyError with inline admin, when inline model's ID not
displayed
----------------------------------+-----------------------------------------
Reporter: handelaar | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: 1.1
Keywords: | Stage: Unreviewed
Has_patch: 0 |
----------------------------------+-----------------------------------------
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 admin.py 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 admin.py and models.py and the traceback generated
when the admin barfs.

--
Ticket URL: <http://code.djangoproject.com/ticket/12599>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 13, 2010, 9:38:00 AM1/13/10
to djang...@holovaty.com, django-...@googlegroups.com
#12599: MultiValueDictKeyError with inline admin, when inline model's ID not
displayed
-------------------------------------------+--------------------------------
Reporter: handelaar | Owner: nobody
Status: closed | Milestone:
Component: django.contrib.admin | Version: 1.1
Resolution: invalid | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by kmtracey):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0

Comment:

If you don't what 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.

--
Ticket URL: <http://code.djangoproject.com/ticket/12599#comment:1>
Reply all
Reply to author
Forward
0 new messages