diff --git a/django/forms/models.py b/django/forms/models.py
index cf465ad..776a33c 100644
a
|
b
|
class BaseModelForm(BaseForm):
|
247 | 247 | def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, |
248 | 248 | initial=None, error_class=ErrorList, label_suffix=':', |
249 | 249 | empty_permitted=False, instance=None): |
| 250 | from django.db.models.signals import post_save |
250 | 251 | opts = self._meta |
251 | 252 | if instance is None: |
252 | 253 | if opts.model is None: |
… |
… |
class BaseModelForm(BaseForm):
|
255 | 256 | self.instance = opts.model() |
256 | 257 | object_data = {} |
257 | 258 | self.instance._adding = True |
| 259 | def cleanup_adding(instance, created, raw, using, **kwargs): |
| 260 | if self.instance is instance: |
| 261 | instance._adding = False |
| 262 | post_save.disconnect(cleanup_adding, opts.model) |
| 263 | post_save.connect(receiver=cleanup_adding, sender=opts.model) |
258 | 264 | else: |
259 | 265 | self.instance = instance |
260 | 266 | self.instance._adding = False |