#16701: FormMixin.initial is shared between all child classes
-----------------------+-------------------------------
Reporter: wilfred@… | Owner: nobody
Type: Bug | Status: new
Milestone: | Component: Generic views
Version: 1.3 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Easy pickings: 0
UI/UX: 0 |
-----------------------+-------------------------------
FormMixin in django/views/generic.py has an `initial` class variable. This
is bad because it is shared between classes. If I do the following:
{{{
class MyUpdateView(BaseUpdateView, TemplateView):
form_class = ArtworkForm
template_name = 'admin/admin__artwork_create_or_update.html'
def get_initial(self):
initial = super(MyUpdateView, self).get_initial()
initial['level'] = self.artwork.level
initial['artist'] = self.artwork.artist
return initial
}}}
this causes me problems because I also have a create view:
{{{
class MyCreateView(BaseCreateView, TemplateView):
template_name = 'admin/admin__artwork_create_or_update.html'
form_class = ArtworkForm
}}}
and this create view ends up with the initial values I only want for
updating. It would be much better if this were an instance attribute.
Patch attached, I hope it's OK.
--
Ticket URL: <https://code.djangoproject.com/ticket/16701>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.