=== modified file 'django/contrib/admin/options.py'
|
|
|
129 | 129 | filter_vertical = () |
130 | 130 | filter_horizontal = () |
131 | 131 | prepopulated_fields = {} |
| 132 | base_form = forms.BaseForm |
132 | 133 | |
133 | 134 | def __init__(self): |
134 | 135 | # TODO: This should really go in django.core.validation, but validation |
… |
… |
|
424 | 425 | post_url = '../../../' |
425 | 426 | |
426 | 427 | fields = flatten_fieldsets(self.fieldsets_add(request)) |
427 | | ModelForm = forms.form_for_model(model, fields=fields, formfield_callback=self.formfield_for_dbfield) |
| 428 | ModelForm = forms.form_for_model(model, fields=fields, form=self.base_form, formfield_callback=self.formfield_for_dbfield) |
428 | 429 | |
429 | 430 | inline_formsets = [] |
430 | 431 | if request.method == 'POST': |
… |
… |
|
486 | 487 | return self.add_view(request, form_url='../../add/') |
487 | 488 | |
488 | 489 | fields = flatten_fieldsets(self.fieldsets_change(request, obj)) |
489 | | ModelForm = forms.form_for_instance(obj, fields=fields, formfield_callback=self.formfield_for_dbfield) |
| 490 | ModelForm = forms.form_for_instance(obj, fields=fields, form=self.base_form, formfield_callback=self.formfield_for_dbfield) |
490 | 491 | |
491 | 492 | inline_formsets = [] |
492 | 493 | if request.method == 'POST': |
… |
… |
|
669 | 670 | def formset_add(self, request): |
670 | 671 | """Returns an InlineFormSet class for use in admin add views.""" |
671 | 672 | fields = flatten_fieldsets(self.fieldsets_add(request)) |
672 | | return forms.inline_formset(self.parent_model, self.model, fk_name=self.fk_name, fields=fields, formfield_callback=self.formfield_for_dbfield, extra=self.extra) |
| 673 | return forms.inline_formset(self.parent_model, self.model, fk_name=self.fk_name, fields=fields, form=self.base_form, formfield_callback=self.formfield_for_dbfield, extra=self.extra) |
673 | 674 | |
674 | 675 | def formset_change(self, request, obj): |
675 | 676 | """Returns an InlineFormSet class for use in admin change views.""" |
676 | 677 | fields = flatten_fieldsets(self.fieldsets_change(request, obj)) |
677 | | return forms.inline_formset(self.parent_model, self.model, fk_name=self.fk_name, fields=fields, formfield_callback=self.formfield_for_dbfield, extra=self.extra) |
| 678 | return forms.inline_formset(self.parent_model, self.model, fk_name=self.fk_name, fields=fields, form=self.base_form, formfield_callback=self.formfield_for_dbfield, extra=self.extra) |
678 | 679 | |
679 | 680 | def _fieldsets(self, request): |
680 | 681 | if self.fieldsets: |
=== modified file 'django/contrib/admin/templates/admin/change_form.html'
|
|
|
37 | 37 | {% if adminform.form.errors %} |
38 | 38 | <p class="errornote"> |
39 | 39 | {% blocktrans count adminform.form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %} |
| 40 | {{ adminform.form.non_field_errors }} |
40 | 41 | </p> |
41 | 42 | {% endif %} |
42 | 43 | |
=== modified file 'django/newforms/models.py'
|
|
|
305 | 305 | new_obj = self.model(**kwargs) |
306 | 306 | return save_instance(form, new_obj, commit=commit) |
307 | 307 | |
308 | | def inline_formset(parent_model, model, fk_name=None, fields=None, extra=3, orderable=False, deletable=True, formfield_callback=lambda f: f.formfield()): |
| 308 | def inline_formset(parent_model, model, fk_name=None, fields=None, extra=3, orderable=False, deletable=True, form=BaseForm, formfield_callback=lambda f: f.formfield()): |
309 | 309 | """ |
310 | 310 | Returns an ``InlineFormset`` for the given kwargs. |
311 | 311 | |
… |
… |
|
325 | 325 | raise Exception("%s has more than 1 ForeignKey to %s" % (model, parent_model)) |
326 | 326 | # let the formset handle object deletion by default |
327 | 327 | FormSet = formset_for_model(model, formset=InlineFormset, fields=fields, |
328 | | formfield_callback=formfield_callback, |
| 328 | form=form, formfield_callback=formfield_callback, |
329 | 329 | extra=extra, orderable=orderable, |
330 | 330 | deletable=deletable) |
331 | 331 | # HACK: remove the ForeignKey to the parent from every form |