#10287: Formset documentation has no information about practical formset 
validation
------------------------------------+---------------------------------------
          Reporter:  aidan          |         Owner:  andrewbadr    
            Status:  new            |     Milestone:  1.1           
         Component:  Documentation  |       Version:  1.0           
        Resolution:                 |      Keywords:  docs, formsets
             Stage:  Accepted       |     Has_patch:  1             
        Needs_docs:  0              |   Needs_tests:  0             
Needs_better_patch:  0              |  
------------------------------------+---------------------------------------
Changes (by andrewbadr):

  * has_patch:  0 => 1

Comment:

 This patch adds a more realistic example to the formset-level `clean`
 method. It also expands the first example in the "Formset validation"
 section so that it matches the later example, and to better explain the
 contents of `formset.errors`.

 Like several methods in the internal formset code, the example `clean` in
 this patch iterates only through the first `self.total_form_count()`
 entries in `self.forms`. This seems to be safer than iterating
 `self.forms` directly, because we may not use all the initial forms, or we
 may try to use more than `max_num`. If I'm wrong about this, the example
 `clean` should be changed to simply iterate through `self.forms` directly.
 That's what some other methods do, and I'm not confident that I understand
 the difference.

 Also, my `clean` method accesses the forms' `cleaned_data` manually
 instead of using the formset's `self.cleaned_data`. This is mainly because
 of a comment on `self.cleaned_data` saying "Maybe this should just go
 away?", but also because `self.cleaned_data` iterates through
 `self.forms`, which I'm confused about (see above). If this is changed,
 the guard checking `any(self.errors)` must be kept, or else users
 accessing `self.cleaned_data` with form-level validation errors will get
 an uncaught exception.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10287#comment:4>
Django <http://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