formfield_callback is lost in an inherited ModelForm
|Reported by:||Ilya Semenov||Owned by:||nobody|
|Cc:||tom@…, vlastimil.zima@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||no||Patch needs improvement:||yes|
Consider the following code:
class BaseTicketForm(forms.ModelForm): class Meta: fields = (...) formfield_callback = lambda f: .... class AddTicketForm(BaseTicketForm): pass class EditTicketForm(BaseTicketForm): # some logic related to editing tickets here
When an instance of AddTicketForm or EditTicketForm is created, a user would expect that formfield_callback is applied. However, the current implementation doesn't do that; instead, a user is forced to copy-paste formfield_callback to each and every derived class.