Opened 2 years ago

Closed 2 years ago

#26456 closed New feature (wontfix)

Document formfield_callback attribute in ModelForm

Reported by: Vlastimil Zíma Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When creating a form from model, the most effective way for modification of several fields at once is formfield_callback. While it is documented argument of modelform_factory which is used for dynamically created forms, the attribute formfield_callback on statically defined ModelForm remains undocumented. There is growing evidence, that despite it isn't documented it is generally used or required, see #17924, http://stackoverflow.com/questions/660929/how-do-you-change-the-default-widget-for-all-django-date-fields-in-a-modelform, http://stackoverflow.com/questions/7342925/django-problem-inheriting-formfield-callback-in-modelforms

I don't require any change of functionality, I just want the following two methods to create a model form to be equal:

# This works, but it's hard to read on a module level.
MyModelForm = modelform_factory(MyModel, formfield_callback=my_callback)

# This does the same thing, but it's not documented.
class MyModelForm(forms.ModelForm):
    formfield_callback = my_callback

    class Meta:
        model = MyModel

Change History (2)

comment:1 Changed 2 years ago by Vlastimil Zíma

Component: UncategorizedDocumentation
Version: 1.9master

comment:2 Changed 2 years ago by Tim Graham

Resolution: wontfix
Status: newclosed
Type: UncategorizedNew feature

The attribute is described as an "internal implementation detail" in #12915 and the possibility of moving it to Meta is discussed. Therefore, I don't think it's a good idea to document it as currently implemented.

Note: See TracTickets for help on using tickets.
Back to Top