Ticket #3815: subclass_form.2.diff
File subclass_form.2.diff, 1.4 KB (added by , 17 years ago) |
---|
-
django/newforms/forms.py
48 48 for base in bases[::-1]: 49 49 if hasattr(base, 'base_fields'): 50 50 fields = base.base_fields.items() + fields 51 # If this is a model_for_* form, it could also have a base_fields 52 # attribute. 53 if 'base_fields' in attrs and isinstance(attrs['base_fields'], dict): 54 fields += attrs['base_fields'].items() 51 55 52 56 attrs['base_fields'] = SortedDictFromList(fields) 53 57 return type.__new__(cls, name, bases, attrs) -
tests/modeltests/model_forms/models.py
560 560 True 561 561 >>> f.cleaned_data 562 562 {'phone': u'312-555-1212', 'description': u'Assistance'} 563 564 # Subclassing using Form ###################################################### 565 566 >>> CategoryForm = form_for_model(Category, form=Form) 567 >>> print CategoryForm().base_fields.keys() 568 ['name', 'slug', 'url'] 569 >>> class CategoryWithCommentForm(CategoryForm): 570 ... comment = CharField() 571 >>> print CategoryWithCommentForm().base_fields.keys() 572 ['name', 'slug', 'url', 'comment'] 563 573 """}