Opened 16 years ago

Last modified 5 years ago

#10305 new

contrib/admin/options.py add_view, change_view — at Initial Version

Reported by: tangc Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords: add_view, change_view, ModelForm
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

add_view, change_view has the following code:

ModelForm = self.get_form(request)
...

form = ModelForm(request.POST, request.FILES)

or

form = ModelForm(initial=initial)

or

form = ModelForm(request.POST, request.FILES, instance=obj)

I would propose:

if isinstance(ModelForm, ModelFormMetaclass):

form = ModelForm(request.POST, request.FILES)

else

form = ModelForm

This way gives the flexibility to override the function get_form(self, request, obj=None, kwargs), which could return a modelform_factory(self.model, defaults) or an instance of a model form.

Change History (1)

by tangc, 16 years ago

Attachment: T10305.diff added
Note: See TracTickets for help on using tickets.
Back to Top