Changes between Initial Version and Version 5 of Ticket #10305


Ignore:
Timestamp:
May 13, 2011, 8:54:35 AM (13 years ago)
Author:
Julien Phalip
Comment:

Reformatted description to be more readable.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #10305

    • Property Triage Stage UnreviewedDesign decision needed
    • Property Milestone post-1.0
    • Property Summary contrib/admin/options.py add_view, change_viewchange the way ModelForms are instantiated in add_view, change_view
    • Property SeverityNormal
    • Property TypeNew feature
    • Property Easy pickings unset
  • Ticket #10305 – Description

    initial v5  
    1 add_view, change_view has the following code:
     1`add_view` and `change_view` have the following code:
    22
     3{{{#!python
    34ModelForm = self.get_form(request)
    45...
     6form = ModelForm(request.POST, request.FILES)
     7}}}
    58
    6  form = ModelForm(request.POST, request.FILES)
    7 or
     9or:
     10{{{#!python
    811 form = ModelForm(initial=initial)
    9 or
     12}}}
     13
     14or:
     15{{{#!python
    1016 form = ModelForm(request.POST, request.FILES, instance=obj)
     17}}}
    1118
    1219I would propose:
    13 
     20{{{#!python
    1421if isinstance(ModelForm, ModelFormMetaclass):
    1522    form = ModelForm(request.POST, request.FILES)
    1623else
    1724    form = ModelForm
     25}}}
    1826
    19 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.
     27This 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.
Back to Top