diff --git a/django/forms/models.py b/django/forms/models.py
index 5edbbd376f..2f08747091 100644
|
a
|
b
|
class BaseModelForm(BaseForm):
|
| 281 | 281 | opts = self._meta |
| 282 | 282 | if opts.model is None: |
| 283 | 283 | raise ValueError('ModelForm has no model class specified.') |
| | 284 | |
| | 285 | object_data = {} |
| | 286 | |
| | 287 | if initial is not None: |
| | 288 | object_data.update(initial) |
| | 289 | |
| 284 | 290 | if instance is None: |
| 285 | 291 | # if we didn't get an instance, instantiate a new one |
| 286 | 292 | self.instance = opts.model() |
| 287 | | object_data = {} |
| 288 | 293 | else: |
| 289 | 294 | self.instance = instance |
| 290 | | object_data = model_to_dict(instance, opts.fields, opts.exclude) |
| 291 | | # if initial was provided, it should override the values from instance |
| 292 | | if initial is not None: |
| 293 | | object_data.update(initial) |
| | 295 | object_data.update(model_to_dict(instance, opts.fields, opts.exclude)) |
| | 296 | |
| 294 | 297 | # self._validate_unique will be set to True by BaseModelForm.clean(). |
| 295 | 298 | # It is False by default so overriding self.clean() and failing to call |
| 296 | 299 | # super will stop validate_unique from being called. |