#5524: Cleaned form data should not be deleted if other data is invalid.
-----------------------------+------------------------------------
     Reporter:  __hawkeye__  |                    Owner:
         Type:  Bug          |                   Status:  new
    Component:  Forms        |                  Version:  SVN
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Accepted
    Has patch:  1            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  0
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+------------------------------------

Comment (by ris):

 I often find myself using the pattern

 {{{
 form = BananaForm ( request.GET )

 if not form.is_valid ():
         # probably very APIFRAGILE, but we need the remnants of the
 cleaned_data
         # containing the bits of form that did validate.
         form.cleaned_data = {}
         form._clean_fields ()
         form = BananaForm ( initial = form.cleaned_data )
 }}}

 so I can supply arbitrary pre-filled-out form elements in a GET string to
 a view that only usually POSTs to itself. Doing it this way allows just
 the supplied (and I suppose valid) elements to be filled in without nasty
 error messages for e.g. required fields that weren't.

 I would love to be able to remove such flaky bits from my code.

 I would have personally suggested moving/renaming cleaned_data to
 something else (partial_cleaned_data?) when overall validation fails
 rather than just not deleting it. Some existing code may be implicitly
 relying on the existence of cleaned_data to signify the form as being
 valid.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/5524#comment:15>
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.

Reply via email to