Ticket #12285: 12285.diff

File 12285.diff, 1.1 KB (added by Travis Cline <travis.cline@…>, 15 years ago)
  • django/forms/models.py

    diff --git a/django/forms/models.py b/django/forms/models.py
    index 61ff8e4..07a1d7b 100644
    a b class BaseModelForm(BaseForm):  
    214214                 empty_permitted=False, instance=None):
    215215        opts = self._meta
    216216        if instance is None:
     217            if not opts.model:
     218                raise Exception('ModelForm has no model class specified')
    217219            # if we didn't get an instance, instantiate a new one
    218220            self.instance = opts.model()
    219221            object_data = {}
  • tests/modeltests/model_forms/models.py

    diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
    index 0fd24c1..3d2fa1e 100644
    a b False  
    15431543>>> f.is_valid()
    15441544True
    15451545
     1546>>> class NoModelModelForm(ModelForm):
     1547...     pass
     1548
     1549>>> f = NoModelModelForm()
     1550Traceback (most recent call last):
     1551    ...
     1552Exception: ModelForm has no model class specified
     1553
    15461554# Clean up
    15471555>>> import shutil
    15481556>>> shutil.rmtree(temp_storage_dir)
Back to Top