Opened 9 years ago
Closed 9 years ago
#27660 closed Bug (invalid)
clean() not called on ModelForm for UpdateView
| Reported by: | Benjamin von Deschwanden | Owned by: | nobody | 
|---|---|---|---|
| Component: | Forms | Version: | 1.10 | 
| Severity: | Normal | Keywords: | ModelForm, UpdateView, clean() | 
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description
I am using a ModelForm as the 'form' attribute of an UpdateView. Overriding the clean() method of the ModelForm does not work; the method does not seem to be called. The undesired behavior can be reconstructed as follows:
- Set up new django project
- Create view and form:
    class RouteUpdate(UpdateView):
        model = Route
        form_class = RouteForm
    class RouteForm(ModelForm):
        class Meta:
            model = Route
            fields = [...]
        def clean(self):
            cleaned_data = super(RouteForm, self).clean()
            print("This method will not be executed...")
            return cleaned_data
      
  Note:
 See   TracTickets
 for help on using tickets.