diff --git a/django/forms/models.py b/django/forms/models.py
index 61ff8e4..07a1d7b 100644
a
|
b
|
class BaseModelForm(BaseForm):
|
214 | 214 | empty_permitted=False, instance=None): |
215 | 215 | opts = self._meta |
216 | 216 | if instance is None: |
| 217 | if not opts.model: |
| 218 | raise Exception('ModelForm has no model class specified') |
217 | 219 | # if we didn't get an instance, instantiate a new one |
218 | 220 | self.instance = opts.model() |
219 | 221 | object_data = {} |
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
index 0fd24c1..3d2fa1e 100644
a
|
b
|
False
|
1543 | 1543 | >>> f.is_valid() |
1544 | 1544 | True |
1545 | 1545 | |
| 1546 | >>> class NoModelModelForm(ModelForm): |
| 1547 | ... pass |
| 1548 | |
| 1549 | >>> f = NoModelModelForm() |
| 1550 | Traceback (most recent call last): |
| 1551 | ... |
| 1552 | Exception: ModelForm has no model class specified |
| 1553 | |
1546 | 1554 | # Clean up |
1547 | 1555 | >>> import shutil |
1548 | 1556 | >>> shutil.rmtree(temp_storage_dir) |