Changes between Version 3 and Version 4 of Ticket #15602, comment 12


Ignore:
Timestamp:
Jan 22, 2015, 8:49:58 PM (10 years ago)
Author:
David Isaacson

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #15602, comment 12

    v3 v4  
    77The only real "solutions" that come to mind both involve _underscore methods, which is exactly what you're not supposed to do:
    88
    9 - The simplest is to allow the custom model form class to be created with `exclude=()`, and let the individual forms in the formset be instantiated.  Then we'd tweak each form's `_meta.exclude` as we wanted to include the results of its exclude.
     9- The simplest is to allow the custom model form class to be created with `exclude=()`, and let the individual forms in the formset be instantiated.  Then we'd tweak each form's `_meta.exclude` as we wanted to include the results of its `get_readonly_fields`.
    1010
    1111- Another possibility is to use a custom `formset` that overrides `BaseModelFormSet._construct_form`, the method that model formsets use to get each model instance in the queryset and to instantiate each of their individual forms.  Instead of instantiating the formset's normal form, we'd have to check the readonly fields on the instance, create a new model form class for that particular exclude list, and instantiate a single instance of that class.  Whew.
Back to Top