1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #15877 -- Improved exception when ModelForm has no model class

Thanks theaspect at gmail.com for the report and volrath for the
patch.
This commit is contained in:
Claude Paroz
2013-02-23 18:29:56 +01:00
parent a05ab448f7
commit cc53d9b30b
2 changed files with 18 additions and 2 deletions

View File

@@ -233,9 +233,9 @@ class BaseModelForm(BaseForm):
initial=None, error_class=ErrorList, label_suffix=':',
empty_permitted=False, instance=None):
opts = self._meta
if opts.model is None:
raise ValueError('ModelForm has no model class specified.')
if instance is None:
if opts.model is None:
raise ValueError('ModelForm has no model class specified.')
# if we didn't get an instance, instantiate a new one
self.instance = opts.model()
object_data = {}