Opened 8 years ago

Closed 8 years ago

#26456 closed New feature (wontfix)

Document formfield_callback attribute in ModelForm

Reported by: Vlastimil Zíma Owned by: nobody
Component: Documentation Version: dev
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 by Vlastimil Zíma, 8 years ago

Component: UncategorizedDocumentation
Version: 1.9master

comment:2 by Tim Graham, 8 years ago

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