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.

According to the ticket's flags, the next step(s) to move this issue forward are:

  • To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is: [https://github.com/django/django/pull/#### PR].

Change History (1)

by tangc, 16 years ago

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