[Django] #26456: Document formfield_callback attribute in ModelForm

1 view
Skip to first unread message

Django

unread,
Apr 4, 2016, 8:22:29 AM4/4/16
to django-...@googlegroups.com
#26456: Document formfield_callback attribute in ModelForm
-------------------------------+--------------------
Reporter: vzima | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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:
{{{
#!python
# 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
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26456>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 4, 2016, 8:27:09 AM4/4/16
to django-...@googlegroups.com
#26456: Document formfield_callback attribute in ModelForm
-------------------------------+--------------------------------------

Reporter: vzima | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by vzima):

* needs_docs: => 0
* version: 1.9 => master
* component: Uncategorized => Documentation
* needs_tests: => 0
* needs_better_patch: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26456#comment:1>

Django

unread,
Apr 4, 2016, 8:37:36 AM4/4/16
to django-...@googlegroups.com
#26456: Document formfield_callback attribute in ModelForm
-------------------------------+--------------------------------------
Reporter: vzima | Owner: nobody
Type: New feature | Status: closed
Component: Documentation | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* type: Uncategorized => New feature
* resolution: => wontfix


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/26456#comment:2>

Reply all
Reply to author
Forward
0 new messages