Opened 18 years ago
Closed 16 years ago
#3188 closed defect (invalid)
OneToOne field - ChangeManipulator looks for related primary key
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | normal | Keywords: | |
Cc: | alex@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Attachments (1)
Change History (7)
by , 18 years ago
Attachment: | patch.diff added |
---|
comment:1 by , 18 years ago
Cc: | added |
---|
Hi Frankie,
Thank you very much for a correct patch. It does work for me well.
Alex
comment:2 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:3 by , 18 years ago
Aha, I see what has been done. It looks my patch has been included here from dpaste.com
The real reasons why I did not included the patch directly here is simple: I fixed the problem without deep understanding of the problem itself. All I did is a quick & dirty fix which fixes the consequence, but I have no idea how the "right" fix should be. Probably only the author of the code have better understanding how the things has been done.
Probably soon all this will be deprecated since the Django will move admin to newforms. Until then this patch can be used by people who are affected by this bug, but including this patch to main tree would be too ugly since the patch ugly itself.... It does "type check" what is considered bad in Python world...
comment:4 by , 18 years ago
Has patch: | set |
---|---|
Triage Stage: | Design decision needed → Accepted |
Marking this accepted since it is a bug.
comment:5 by , 18 years ago
Needs tests: | set |
---|
Could someone please write a unit test that shows this bug.
comment:6 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
oldforms is going away and is no longer supported. This should be working now in trunk via newforms. If not it should be reported as a new ticket.
Patch in the correct format and in the correct place.