1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

Fixed bug for OneToOneFields in the admin -- the manipulator_validator_unique wasn't doing the correct lookup

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1322 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2005-11-21 01:39:18 +00:00
parent b96f6059f0
commit 7a80b2cc98
2 changed files with 3 additions and 10 deletions

View File

@@ -48,11 +48,11 @@ def manipulator_valid_rel_key(f, self, field_data, all_data):
def manipulator_validator_unique(f, opts, self, field_data, all_data):
"Validates that the value is unique for this field."
if f.rel and isinstance(f.rel, ManyToOne):
lookup_type = 'pk'
lookup_type = '%s__%s__exact' % (f.name, f.rel.get_related_field().name)
else:
lookup_type = 'exact'
lookup_type = '%s__exact' % (f.name, lookup_type)
try:
old_obj = opts.get_model_module().get_object(**{'%s__%s' % (f.name, lookup_type): field_data})
old_obj = opts.get_model_module().get_object(**{lookup_type: field_data})
except ObjectDoesNotExist:
return
if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.attname) == getattr(old_obj, opts.pk.attname):