Ticket #494: 494.5.patch
File 494.5.patch, 7.3 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
443 443 super(BaseModelFormSet, self).add_fields(form, index) 444 444 445 445 def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.formfield(), 446 formset=BaseModelFormSet, 446 formset=BaseModelFormSet, classes=[], 447 447 extra=1, can_delete=False, can_order=False, 448 448 max_num=0, fields=None, exclude=None): 449 449 """ … … 452 452 form = modelform_factory(model, form=form, fields=fields, exclude=exclude, 453 453 formfield_callback=formfield_callback) 454 454 FormSet = formset_factory(form, formset, extra=extra, max_num=max_num, 455 can_order=can_order, can_delete=can_delete) 455 can_order=can_order, can_delete=can_delete, 456 classes=classes) 456 457 FormSet.model = model 457 458 return FormSet 458 459 … … 543 544 544 545 def inlineformset_factory(parent_model, model, form=ModelForm, 545 546 formset=BaseInlineFormSet, fk_name=None, 546 fields=None, exclude=None, 547 fields=None, exclude=None, classes=[], 547 548 extra=3, can_order=False, can_delete=True, max_num=0, 548 549 formfield_callback=lambda f: f.formfield()): 549 550 """ … … 573 574 'fields': fields, 574 575 'exclude': exclude, 575 576 'max_num': max_num, 577 'classes': classes, 576 578 } 577 579 FormSet = modelformset_factory(model, **kwargs) 578 580 FormSet.fk = fk -
django/contrib/admin/options.py
816 816 template = None 817 817 verbose_name = None 818 818 verbose_name_plural = None 819 classes = [] 819 820 820 821 def __init__(self, parent_model, admin_site): 821 822 self.admin_site = admin_site … … 832 833 js = [] 833 834 if self.prepopulated_fields: 834 835 js.append('js/urlify.js') 836 if 'collapse' in self.classes: 837 js.append('js/admin/CollapsedFieldsets.js') 835 838 if self.filter_vertical or self.filter_horizontal: 836 839 js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js']) 837 840 return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js]) … … 856 859 "formfield_callback": curry(self.formfield_for_dbfield, request=request), 857 860 "extra": self.extra, 858 861 "max_num": self.max_num, 862 "classes": self.classes, 859 863 } 860 864 defaults.update(kwargs) 861 865 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
877 877 An override to the ``verbose_name_plural`` found in the model's inner ``Meta`` 878 878 class. 879 879 880 ``classes`` 881 ~~~~~~~~~~~ 882 883 .. versionadded:: development 884 885 A list containing extra CSS classes to apply to the inline. 886 887 Example:: 888 889 class BookInline(admin.TabularInline): 890 classes = ['collapse', 'extrapretty'] 891 892 A useful class is ``collapse``, which will cause the inline to be initially 893 collapsed. 894 880 895 Working with a model with two or more foreign keys to the same parent model 881 896 --------------------------------------------------------------------------- 882 897