OneToOne field - ChangeManipulator looks for related primary key
|Reported by:||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||no|
I am posting it as bug, I have already tried to post to django-developers, no feedback has been received.
Assume I relate django.contrib.auth.User to Customer using OneToOne relation. If I do this,
I am unable to edit this user via /admin since ChangeManipulator brings up this error:
Exception Type: KeyError Exception Value: 'user' Exception Location: /usr/lib64/python2.4/site-packages/django/db/models/manipulators.py in save, line 163
Obviously, this is because Manipulator tries to use related field ID as
for ForeignKey, but it
seems to be wrong approach, since with OneToOne field we should
directly search on User.
I have tried to change the code to something like this:
And it works fine for me. I am submitting this as working patch,
but I consider it to be a temp. solution only.