Ticket #4727: newforms-admin-base-form.diff

File newforms-admin-base-form.diff, 4.2 KB (added by Petr Marhoun <petr.marhoun@…>, 17 years ago)
  • django/contrib/admin/options.py

    === modified file 'django/contrib/admin/options.py'
     
    129129    filter_vertical = ()
    130130    filter_horizontal = ()
    131131    prepopulated_fields = {}
     132    base_form = forms.BaseForm
    132133
    133134    def __init__(self):
    134135        # TODO: This should really go in django.core.validation, but validation
     
    424425            post_url = '../../../'
    425426
    426427        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)
    428429
    429430        inline_formsets = []
    430431        if request.method == 'POST':
     
    486487            return self.add_view(request, form_url='../../add/')
    487488
    488489        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)
    490491
    491492        inline_formsets = []
    492493        if request.method == 'POST':
     
    669670    def formset_add(self, request):
    670671        """Returns an InlineFormSet class for use in admin add views."""
    671672        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)
    673674
    674675    def formset_change(self, request, obj):
    675676        """Returns an InlineFormSet class for use in admin change views."""
    676677        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)
    678679
    679680    def _fieldsets(self, request):
    680681        if self.fieldsets:
  • django/contrib/admin/templates/admin/change_form.html

    === modified file 'django/contrib/admin/templates/admin/change_form.html'
     
    3737{% if adminform.form.errors %}
    3838    <p class="errornote">
    3939    {% 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 }}
    4041    </p>
    4142{% endif %}
    4243
  • django/newforms/models.py

    === modified file 'django/newforms/models.py'
     
    305305        new_obj = self.model(**kwargs)
    306306        return save_instance(form, new_obj, commit=commit)
    307307
    308 def inline_formset(parent_model, model, fk_name=None, fields=None, extra=3, orderable=False, deletable=True, formfield_callback=lambda f: f.formfield()):
     308def inline_formset(parent_model, model, fk_name=None, fields=None, extra=3, orderable=False, deletable=True, form=BaseForm, formfield_callback=lambda f: f.formfield()):
    309309    """
    310310    Returns an ``InlineFormset`` for the given kwargs.
    311311   
     
    325325            raise Exception("%s has more than 1 ForeignKey to %s" % (model, parent_model))
    326326    # let the formset handle object deletion by default
    327327    FormSet = formset_for_model(model, formset=InlineFormset, fields=fields,
    328                                 formfield_callback=formfield_callback,
     328                                form=form, formfield_callback=formfield_callback,
    329329                                extra=extra, orderable=orderable,
    330330                                deletable=deletable)
    331331    # HACK: remove the ForeignKey to the parent from every form
Back to Top