Ticket #494: 494.4.patch
File 494.4.patch, 7.2 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
435 435 super(BaseModelFormSet, self).add_fields(form, index) 436 436 437 437 def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.formfield(), 438 formset=BaseModelFormSet, 438 formset=BaseModelFormSet, classes=[], 439 439 extra=1, can_delete=False, can_order=False, 440 440 max_num=0, fields=None, exclude=None): 441 441 """ … … 444 444 form = modelform_factory(model, form=form, fields=fields, exclude=exclude, 445 445 formfield_callback=formfield_callback) 446 446 FormSet = formset_factory(form, formset, extra=extra, max_num=max_num, 447 can_order=can_order, can_delete=can_delete) 447 can_order=can_order, can_delete=can_delete, 448 classes=classes) 448 449 FormSet.model = model 449 450 return FormSet 450 451 … … 530 531 531 532 def inlineformset_factory(parent_model, model, form=ModelForm, 532 533 formset=BaseInlineFormSet, fk_name=None, 533 fields=None, exclude=None, 534 fields=None, exclude=None, classes=[], 534 535 extra=3, can_order=False, can_delete=True, max_num=0, 535 536 formfield_callback=lambda f: f.formfield()): 536 537 """ … … 560 561 'fields': fields, 561 562 'exclude': exclude, 562 563 'max_num': max_num, 564 'classes': classes, 563 565 } 564 566 FormSet = modelformset_factory(model, **kwargs) 565 567 FormSet.fk = fk -
django/contrib/admin/options.py
751 751 template = None 752 752 verbose_name = None 753 753 verbose_name_plural = None 754 classes = [] 754 755 755 756 def __init__(self, parent_model, admin_site): 756 757 self.admin_site = admin_site … … 767 768 js = [] 768 769 if self.prepopulated_fields: 769 770 js.append('js/urlify.js') 771 if 'collapse' in self.classes: 772 js.append('js/admin/CollapsedFieldsets.js') 770 773 if self.filter_vertical or self.filter_horizontal: 771 774 js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js']) 772 775 return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js]) … … 791 794 "formfield_callback": self.formfield_for_dbfield, 792 795 "extra": self.extra, 793 796 "max_num": self.max_num, 797 "classes": self.classes, 794 798 } 795 799 defaults.update(kwargs) 796 800 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 }} … … 25 26 {# <ul class="tools"> #} 26 27 {# <li><a class="add" href="">Add another {{ inline_admin_formset.opts.verbose_name|title }}</a></li> #} 27 28 {# </ul> #} 29 </fieldset> 28 30 </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> -
django/contrib/contenttypes/generic.py
326 326 def generic_inlineformset_factory(model, form=ModelForm, 327 327 formset=BaseGenericInlineFormSet, 328 328 ct_field="content_type", fk_field="object_id", 329 fields=None, exclude=None, 329 fields=None, exclude=None, classes=[], 330 330 extra=3, can_order=False, can_delete=True, 331 331 max_num=0, 332 332 formfield_callback=lambda f: f.formfield()): … … 350 350 exclude = [ct_field.name, fk_field.name] 351 351 FormSet = modelformset_factory(model, form=form, 352 352 formfield_callback=formfield_callback, 353 formset=formset, 353 formset=formset, classes=classes, 354 354 extra=extra, can_delete=can_delete, can_order=can_order, 355 355 fields=fields, exclude=exclude, max_num=max_num) 356 356 FormSet.ct_field = ct_field -
docs/ref/contrib/admin.txt
776 776 An override to the ``verbose_name_plural`` found in the model's inner ``Meta`` 777 777 class. 778 778 779 ``classes`` 780 ~~~~~~~~~~~ 781 782 .. versionadded:: development 783 784 A list containing extra CSS classes to apply to the inline. 785 786 Example:: 787 788 class BookInline(admin.TabularInline): 789 classes = ['collapse', 'extrapretty'] 790 791 A useful class is ``collapse``, which will cause the inline to be initially 792 collapsed. 793 779 794 Working with a model with two or more foreign keys to the same parent model 780 795 --------------------------------------------------------------------------- 781 796