Ticket #4727: newforms-admin-5559-allow-form-base-override.diff

File newforms-admin-5559-allow-form-base-override.diff, 1.8 KB (added by Honza Král <Honza.Kral@…>, 8 years ago)
  • django/contrib/admin/options.py

     
    162162    filter_vertical = ()
    163163    filter_horizontal = ()
    164164    inlines = []
     165    base_form = forms.BaseForm
    165166
    166167    def __init__(self, model):
    167168        self.model = model
     
    412413            # Object list will give 'Permission Denied', so go back to admin home
    413414            post_url = '../../../'
    414415
    415         ModelForm = forms.form_for_model(model, formfield_callback=self.formfield_for_dbfield)
     416        ModelForm = forms.form_for_model(model, form=self.base_form, formfield_callback=self.formfield_for_dbfield)
    416417
    417418        inline_formsets = []
    418419        if request.POST:
     
    465466        if request.POST and request.POST.has_key("_saveasnew"):
    466467            return self.add_view(request, form_url='../../add/')
    467468
    468         ModelForm = forms.form_for_instance(obj, formfield_callback=self.formfield_for_dbfield)
     469        ModelForm = forms.form_for_instance(obj, form=self.base_form, formfield_callback=self.formfield_for_dbfield)
    469470
    470471        inline_formsets = []
    471472        if request.POST:
  • django/contrib/admin/templates/admin/change_form.html

     
    3838{% if adminform.form.errors %}
    3939    <p class="errornote">
    4040    {% blocktrans count adminform.form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
     41    {{ adminform.form.non_field_errors }}
    4142    </p>
    4243{% endif %}
    4344
Back to Top