Changeset 6917
- Timestamp:
- 12/12/07 21:14:31 (7 months ago)
- Files:
-
- django/trunk/django/newforms/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/model_forms/models.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/newforms/models.py
r6915 r6917 246 246 # If a model is defined, extract form fields from it and add them to base_fields 247 247 if attrs['_meta'].model is not None: 248 # Don't allow a subclass to define a Meta model if a parent class has.249 # Technically the right fields would be generated, but the save250 # method will not deal with more than one model.248 # Don't allow a subclass to define a different Meta model than a 249 # parent class has. Technically the right fields would be generated, 250 # but the save method will not deal with more than one model. 251 251 for base in bases: 252 252 base_opts = getattr(base, '_meta', None) 253 253 base_model = getattr(base_opts, 'model', None) 254 if base_model is not None:255 raise ImproperlyConfigured('%s defines more than one model.' % name)254 if base_model and base_model is not opts.model: 255 raise ImproperlyConfigured('%s defines a different model than its parent.' % name) 256 256 model_fields = fields_for_model(opts.model, opts.fields, opts.exclude) 257 257 # fields declared in base classes override fields from the model django/trunk/tests/modeltests/model_forms/models.py
r6915 r6917 144 144 Traceback (most recent call last): 145 145 ... 146 ImproperlyConfigured: BadForm defines more than one model.146 ImproperlyConfigured: BadForm defines a different model than its parent. 147 147 148 148 >>> class ArticleForm(ModelForm): … … 155 155 ... 156 156 ImproperlyConfigured: BadForm's base classes define more than one model. 157 158 This one is OK since the subclass specifies the same model as the parent. 159 160 >>> class SubCategoryForm(CategoryForm): 161 ... class Meta: 162 ... model = Category 157 163 158 164
