formset factories override any supplied formset max_num
|Reported by:||Keryn Knight <django@…>||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Because of the way formset_factory yields a new object based on a given formset argument, during which it manually sets some attrs on the resulting object, it is impossible for the following to work:
class MyFormset(BaseFormSet): def _max_num(self): return 9000 # or whatever max_num = property(_max_num) FromFactory = formset_factory(MyForm, formset=MyFormset) FromFactory.max_num # will be 1000 FromFactory.max_num = FromFactory._max_num() FromFactory.max_num # will be 9000
It seems inconsiderate for the factory to override the max_num regardless of what the FormSet says is ok, silently.
I've left it uncategorized, because I can see the argument for the way it behaves currently [especially WRT backwards compatibility], but if it's not fixed, it may be worth finding a place in the documentation [docstrings and/or real docs] to indicate the behaviour.