mirror of
https://github.com/django/django.git
synced 2025-06-12 15:09:12 +00:00
magic-removal: Fixed #1159 -- Fixed error in 'unique' manipulator validator
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1828 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9033ba7d36
commit
1885443c82
@ -36,7 +36,7 @@ def manipulator_validator_unique(f, opts, self, field_data, all_data):
|
|||||||
"Validates that the value is unique for this field."
|
"Validates that the value is unique for this field."
|
||||||
lookup_type = f.get_validator_unique_lookup_type()
|
lookup_type = f.get_validator_unique_lookup_type()
|
||||||
try:
|
try:
|
||||||
old_obj = self.__class__._default_manager.get_object(**{lookup_type: field_data})
|
old_obj = self.manager.get_object(**{lookup_type: field_data})
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
return
|
return
|
||||||
if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.attname) == getattr(old_obj, opts.pk.attname):
|
if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.attname) == getattr(old_obj, opts.pk.attname):
|
||||||
|
@ -130,7 +130,7 @@ class AutomaticManipulator(Manipulator, Naming):
|
|||||||
child.do_html2python(new_data)
|
child.do_html2python(new_data)
|
||||||
|
|
||||||
def get_original_value(self, field):
|
def get_original_value(self, field):
|
||||||
raise NotImplemented
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_new_object(self, expanded_data, overrides=None):
|
def get_new_object(self, expanded_data, overrides=None):
|
||||||
params = {}
|
params = {}
|
||||||
@ -204,7 +204,6 @@ class AutomaticManipulator(Manipulator, Naming):
|
|||||||
else:
|
else:
|
||||||
child_manips._do_command_expanded(command_parts)
|
child_manips._do_command_expanded(command_parts)
|
||||||
|
|
||||||
|
|
||||||
def save(self, new_data):
|
def save(self, new_data):
|
||||||
self.update(new_data)
|
self.update(new_data)
|
||||||
self.save_from_update()
|
self.save_from_update()
|
||||||
@ -285,7 +284,7 @@ class ModelAddManipulator(AutomaticManipulator):
|
|||||||
return field.get_default()
|
return field.get_default()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Automatic AddManipulator '%s' for %s>" % (self.name_prefix, self.model.__name__, )
|
return "<Automatic AddManipulator '%s' for %s>" % (self.name_prefix, self.model.__name__)
|
||||||
|
|
||||||
class ModelChangeManipulator(AutomaticManipulator):
|
class ModelChangeManipulator(AutomaticManipulator):
|
||||||
change = True
|
change = True
|
||||||
@ -318,6 +317,10 @@ class ModelChangeManipulator(AutomaticManipulator):
|
|||||||
original_object = opts.get_model_module().Klass(**params)
|
original_object = opts.get_model_module().Klass(**params)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
else:
|
||||||
|
# Save the obj_key even though we already have it, in case it's
|
||||||
|
# currently a string and needs to be an integer.
|
||||||
|
self.obj_key = getattr(original_object, self.model._meta.pk.attname)
|
||||||
|
|
||||||
super(ModelChangeManipulator, self).__init__(original_object=original_object, follow=follow, name_parts=name_parts)
|
super(ModelChangeManipulator, self).__init__(original_object=original_object, follow=follow, name_parts=name_parts)
|
||||||
#self.original_object = original_object
|
#self.original_object = original_object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user