Opened 14 years ago
Closed 14 years ago
#16289 closed New feature (duplicate)
Make FormSet and related classes declarable
Reported by: | Bas Peschier | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | formset |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
FormSets are now created with factories, but similar to ModelForm, it is entirely possible to declare a custom F!ormSet; the only thing missing are the defaults on the base classes in the code.
The idea is that you should be able to do:
class MyFormSet(formsets.FormSet): can_delete = True form = MyForm extra = 3
This is similar how we now teach people how to use ModelForms and opens up possibilities to override/extend behaviour.
Change History (2)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Keywords: | formset added |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Since it's clearly documented that FormSet can be subclassed, and behavior overridden, I'm going to assume that the OP is requesting better support of/docs for a class-based declaration with no use of formset_factory.
That sounds nice. I would like that.
This is related to #10403 but applies to all FormSets, not just ModelFormSets. Marking as duplicate with a note in the other ticket.
This would be very useful for a nicer implementation of the formset derived cbv #16256 .
The BaseInlineFormSet is the only tricky one with the _get_foreign_key() and the max_num override when fk.unique=True .
I'd also move the defaults (e.g. extra=3) to the BaseFormSet and make the factories only pass dict keys whose value isn't None to type().