Ticket #494: 494.3.patch
File 494.3.patch, 4.7 KB (added by , 16 years ago) |
---|
-
django/forms/formsets.py
273 273 return mark_safe(u'\n'.join([unicode(self.management_form), forms])) 274 274 275 275 def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False, 276 can_delete=False, max_num=0 ):276 can_delete=False, max_num=0, classes=[]): 277 277 """Return a FormSet for the given form class.""" 278 attrs = {'form': form, 'extra': extra, 278 attrs = {'form': form, 'extra': extra, 'classes': classes, 279 279 'can_order': can_order, 'can_delete': can_delete, 280 280 'max_num': max_num} 281 281 return type(form.__name__ + 'FormSet', (formset,), attrs) -
django/forms/models.py
418 418 super(BaseModelFormSet, self).add_fields(form, index) 419 419 420 420 def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.formfield(), 421 formset=BaseModelFormSet, 421 formset=BaseModelFormSet, classes=[], 422 422 extra=1, can_delete=False, can_order=False, 423 423 max_num=0, fields=None, exclude=None): 424 424 """ … … 427 427 form = modelform_factory(model, form=form, fields=fields, exclude=exclude, 428 428 formfield_callback=formfield_callback) 429 429 FormSet = formset_factory(form, formset, extra=extra, max_num=max_num, 430 can_order=can_order, can_delete=can_delete) 430 can_order=can_order, can_delete=can_delete, 431 classes=classes) 431 432 FormSet.model = model 432 433 return FormSet 433 434 … … 514 515 515 516 def inlineformset_factory(parent_model, model, form=ModelForm, 516 517 formset=BaseInlineFormSet, fk_name=None, 517 fields=None, exclude=None, 518 fields=None, exclude=None, classes=[], 518 519 extra=3, can_order=False, can_delete=True, max_num=0, 519 520 formfield_callback=lambda f: f.formfield()): 520 521 """ … … 541 542 'fields': fields, 542 543 'exclude': exclude, 543 544 'max_num': max_num, 545 'classes': classes, 544 546 } 545 547 FormSet = modelformset_factory(model, **kwargs) 546 548 FormSet.fk = fk -
django/contrib/admin/options.py
750 750 template = None 751 751 verbose_name = None 752 752 verbose_name_plural = None 753 classes = [] 753 754 754 755 def __init__(self, parent_model, admin_site): 755 756 self.admin_site = admin_site … … 790 791 "formfield_callback": self.formfield_for_dbfield, 791 792 "extra": self.extra, 792 793 "max_num": self.max_num, 794 "classes": self.classes, 793 795 } 794 796 defaults.update(kwargs) 795 797 return inlineformset_factory(self.parent_model, self.model, **defaults) -
django/contrib/admin/templates/admin/edit_inline/stacked.html
1 1 {% load i18n %} 2 2 <div class="inline-group"> 3 <fieldset class="module {% for class in inline_admin_formset.formset.classes %}{{class}}{% endfor %}"> 3 4 <h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2> 4 5 {{ inline_admin_formset.formset.management_form }} 5 6 {{ inline_admin_formset.formset.non_form_errors }} … … 24 25 {# <li><a class="add" href="">Add another {{ inline_admin_formset.opts.verbose_name|title }}</a></li> #} 25 26 {# </ul> #} 26 27 </div> 28 </div> -
django/contrib/admin/templates/admin/edit_inline/tabular.html
2 2 <div class="inline-group"> 3 3 <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}"> 4 4 {{ inline_admin_formset.formset.management_form }} 5 <fieldset class="module ">5 <fieldset class="module {% for class in inline_admin_formset.formset.classes %}{{class}}{% endfor %}"> 6 6 <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2> 7 7 {{ inline_admin_formset.formset.non_form_errors }} 8 8 <table>