#16138: ModelForm's 'initial' attribute expectedly persists cross different instances ------------------------+------------------------------- Reporter: hanson2010 | 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 ------------------------+------------------------------- There are two !UpdateView's (or !CreateView's) A and B with their corresponding !ModelForm A and B. From !UpdateView A the 'initial' attribute in !ModelForm A was set to a certain value. After this, !UpdateView B and !ModelForm B were created. Now the 'initial' attribute in !ModelForm B was not {}, but the '''same''' as !ModelForm A.
{{{ class UpdateViewA(UpdateView): model = Project form_class = ProjectFormA ... def get_form_kwargs(self, **kwargs): kwargs = super(UpdateViewA, self).get_form_kwargs(**kwargs) if self.get_object().kickoff_date == None: kwargs['initial']['kickoff_date'] = datetime.date.today() return kwargs class UpdateViewB(UpdateView): model = Project form_class = ProjectFormB ... class ProjectFormA(ModelForm): ... class Meta: model = Project class ProjectFormB(ModelForm): ... class Meta: model = Project }}} -- Ticket URL: <https://code.djangoproject.com/ticket/16138> 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 django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.