﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
514	[patch] Traceback in admin when adding an object containing a OneToOneField.	mmarshall	Adrian Holovaty	"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):

<snip>

  File ""/usr/lib/python2.4/site-packages/django/core/meta/fields.py"", line 40, in manipulator_validator_unique
    old_obj = opts.get_model_module().get_object(**{'%s__exact' % f.name: field_data})

<snip>

TypeError: got unexpected keyword argument 'node__exact'
}}}

A trivial patch solves the problem:

{{{
Index: django_src/django/core/meta/fields.py
===================================================================
--- django_src/django/core/meta/fields.py       (revision 642)
+++ django_src/django/core/meta/fields.py       (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.""
     try:
-        old_obj = opts.get_model_module().get_object(**{'%s__exact' % f.name: field_data})
+        old_obj = opts.get_model_module().get_object(**{'%s__id__exact' % f.name: field_data})
     except ObjectDoesNotExist:
         return
     if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.column) == getattr(old_obj, opts.pk.column):
}}}

MWM"	defect	closed	contrib.admin	1.0	normal	fixed			Unreviewed	1	0	0	0	0	0
