1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #14234 -- Re-validating a model instance added via ModelForm no longer throws spurious PK uniqueness errors. Thanks to David Reynolds and Jeremy Dunck.

Also moved Model._adding to Model._state.adding to reduce instance namespace footprint.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14612 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Carl Meyer
2010-11-18 22:43:46 +00:00
parent 9cebb526f2
commit 38ba3775ec
4 changed files with 46 additions and 5 deletions

View File

@@ -254,10 +254,10 @@ class BaseModelForm(BaseForm):
# if we didn't get an instance, instantiate a new one
self.instance = opts.model()
object_data = {}
self.instance._adding = True
self.instance._state.adding = True
else:
self.instance = instance
self.instance._adding = False
self.instance._state.adding = False
object_data = model_to_dict(instance, opts.fields, opts.exclude)
# if initial was provided, it should override the values from instance
if initial is not None: