#35843: Changing the rendering order of formsets is not clear
-------------------------------------+-------------------------------------
     Reporter:  Matthew Pava         |                     Type:
                                     |  Cleanup/optimization
       Status:  new                  |                Component:
                                     |  Documentation
      Version:  5.1                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 I have a formset that I'd like to modify the order of the forms in. I did
 overwrite the `forms` `cached_property` with a simple sorted addition to
 the base `forms` `cached_property`, but I soon discovered that data wasn't
 saving properly in some cases.

 Apparently, I went about it all wrong. There's this little tiny tidbit
 here about rendering forms:
 
[https://docs.djangoproject.com/en/5.1/topics/forms/formsets/#:~:text=Iterating%20over%20a%20formset%20will,which%20returns%20the%20corresponding%20form]

 {{{
 Iterating over a formset will render the forms in the order they were
 created. You can change this order by providing an alternate
 implementation for the __iter__() method.

 Formsets can also be indexed into, which returns the corresponding form.
 If you override __iter__, you will need to also override __getitem__ to
 have matching behavior.
 }}}

 Okay, but I've never implemented an `__iter__` method, and based on what
 I've read, you also have to implement a `__next__` method. And you
 explicitly tell me to implement the `__getitem__` method. I understand if
 you don't want to make changing the rendering ordering easier to implement
 in Django; however, I would appreciate more and better documentation
 including an example of how exactly to implement any of these methods to
 change the rendering order of a formset.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35843>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070192922a1b6d-8658581f-f0aa-4d6a-aab6-b4527c7d3617-000000%40eu-central-1.amazonses.com.

Reply via email to