#8562: OneToOnes + primary_key = True ... fails in Admin
--------------------------------------+-------------------------------------
Reporter: magneto | Owner: brosner
Status: assigned | Milestone: 1.0
Component: Admin interface | Version: SVN
Resolution: | Keywords: admin onetoone
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
--------------------------------------+-------------------------------------
Comment (by kmtracey):
I find this ticket confusing also, partly because I do not really know the
code involved but partly because I think there are two completely
unrelated problems described/attempting to be fixed by the patch.
First problem: the widget on the change page for an object containing a
!OneToOne field does not display the current value. It displays as empty.
This problem was introduced by the fix to #7888, if I back up to [8527]
the widget displays the correct value. This is what the patch to
`model_to_dict` appears to be attempting to fix. It's putting the data
value in the dict under both `f.attname` and `f.name` since the former is
apparently what is needed to fix #7888 but that latter is what is needed
for the change page widget to get the value for display. I agree it
doesn't seem right to be mapping the data twice but have no idea what the
right answer is since I don't understand this code.
Second problem, that existed before [8528] and still exists: If you have a
!OneToOne-related object edited inline that shares a primary key with the
parent object, attempting to save the parent object generates a !KeyError
exception. The problem here is the inline form for the child object does
not contain that object's primary key anywhere, and save_existing_objects
assumes a form always contains the pk value for the object. The primary
key field is the same field as the link to the parent object, so it is not
present in the inline forms? At least that is my guess. I think that is
what the changes to add_fields are trying to fix. Again since I don't
know this code I don't know what the correct fix should be.
The 2nd problem is also what was reported in #8241, but I don't see that
it has been fixed, so I'm not sure that should have been closed. I
believe it still exists. Might be more straightforward to use this one to
fix the first problem (widget on change page getting correct value) here,
and reopen #8241 to fix the key error on save of an object with an inline
that shares the same primary key as the parent. I think it is very
confusing to have them both lumped under this one ticket.
--
Ticket URL: <http://code.djangoproject.com/ticket/8562#comment:14>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---