Changes between Initial Version and Version 5 of Ticket #10305


Ignore:
Timestamp:
05/13/2011 08:54:35 AM (4 years ago)
Author:
julien
Comment:

Reformatted description to be more readable.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #10305

    • Property Severity changed from to Normal
    • Property Patch needs improvement unset
    • Property Needs tests unset
    • Property Summary changed from contrib/admin/options.py add_view, change_view to change the way ModelForms are instantiated in add_view, change_view
    • Property Easy pickings unset
    • Property Milestone changed from post-1.0 to
    • Property Needs documentation unset
    • Property Type changed from to New feature
    • Property Triage Stage changed from Unreviewed to Design decision needed
  • 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