#16168: Form validation is bypassed on Admin Inline ModelForms that define extra
fields
------------------------------------+----------------------------
 Reporter:  izzaddin.ruhulessin@…   |          Owner:  nobody
     Type:  Bug                     |         Status:  new
Milestone:                          |      Component:  Forms
  Version:  1.2                     |       Severity:  Normal
 Keywords:  validation, modelforms  |   Triage Stage:  Unreviewed
Has patch:  0                       |  Easy pickings:  1
------------------------------------+----------------------------
 When defining extra/overridden fields on modelforms, validation is
 bypassed. This can lead to errors under some circumstances.

 For example, you have a model 'Book' that defines a ForeignKey to 'Author'
 named 'author'. On your ModelForm you replace this field by a CharField
 (or some other type) for whatever reason.

 On submitting an invalid form, a ValueError will be raised complaining
 that the datatype is incorrect.

 My proposed solution is overriding ModelForm._post_clean():

 {{{
 #!div style="font-size: 80%"
   {{{#!python
 class ModelForm(BaseModelForm):

     def _post_clean(self):
         if len(self._errors) == 0:
             super(ModelForm, self)._post_clean()

   }}}
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16168>
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.

Reply via email to