Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#514 closed defect (fixed)

[patch] Traceback in admin when adding an object containing a OneToOneField.

Reported by: mmarshall Owned by: Adrian Holovaty
Component: contrib.admin Version: 1.0
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Working with objects that have a OneToOneField in the admin works fine when you click on "change" and then select one from the list. However, if you click on "Add", saving the object results in a traceback similar to this (with the rel_name of 'node'):

There's been an error:

Traceback (most recent call last):


  File "/usr/lib/python2.4/site-packages/django/core/meta/", line 40, in manipulator_validator_unique
    old_obj = opts.get_model_module().get_object(**{'%s__exact' % field_data})


TypeError: got unexpected keyword argument 'node__exact'

A trivial patch solves the problem:

Index: django_src/django/core/meta/
--- django_src/django/core/meta/       (revision 642)
+++ django_src/django/core/meta/       (working copy)
@@ -37,7 +37,7 @@
 def manipulator_validator_unique(f, opts, self, field_data, all_data):
     "Validates that the value is unique for this field."
-        old_obj = opts.get_model_module().get_object(**{'%s__exact' % field_data})
+        old_obj = opts.get_model_module().get_object(**{'%s__id__exact' % field_data})
     except ObjectDoesNotExist:
     if hasattr(self, 'original_object') and getattr(self.original_object, == getattr(old_obj,


Change History (2)

comment:1 Changed 13 years ago by mmarshall

Resolution: fixed
Status: newclosed

Fixed in [643].


comment:2 Changed 12 years ago by (none)

milestone: Version 1.0

Milestone Version 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top