[Django] #23656: FormMixin.get_form's form_class argument should be optional

24 views
Skip to first unread message

Django

unread,
Oct 14, 2014, 4:19:33 PM10/14/14
to django-...@googlegroups.com
#23656: FormMixin.get_form's form_class argument should be optional
------------------------------------------------+------------------------
Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Generic views | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Just like we do with `SingleObjectMixin.get_object(queryset=None)` that
defaults on `get_queryset()` we should make
`FormMixin.get_form(form_class)` default on `get_form_class` to make
overriding easier.

The provided patch introduces a backward compatibility issue for users
that overrided `get_form()` on a `ProcessFormView` subclass and expected
`form_class` to be `not None`. It could be addressed by removing the
changes in `ProcessFormView.get()` and `ProcessFormView.post()`.

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

Django

unread,
Oct 17, 2014, 9:19:32 AM10/17/14
to django-...@googlegroups.com
#23656: FormMixin.get_form's form_class argument should be optional
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Generic views | Resolution:
Severity: Normal | Triage Stage: Ready for
Keywords: | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Ready for checkin


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

Django

unread,
Oct 23, 2014, 2:50:26 PM10/23/14
to django-...@googlegroups.com
#23656: FormMixin.get_form's form_class argument should be optional
--------------------------------------+------------------------------------

Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by charettes):

* stage: Ready for checkin => Accepted


Comment:

I'll move it to ''Accepted'' until I either get a consensus on the mailing
list about the backward compatibility issues or I find time to avoid
breaking the following case:

{{{#!python
class MyFormMixin(FormMixin):
def get_form(form_class):
return form_class(...)
}}}

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

Django

unread,
Oct 27, 2014, 8:54:33 AM10/27/14
to django-...@googlegroups.com
#23656: FormMixin.get_form's form_class argument should be optional
--------------------------------------+------------------------------------

Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


Comment:

Okay, marking as "patch needs improvement" in the meantime so this doesn't
appear in the review queue.

--
Ticket URL: <https://code.djangoproject.com/ticket/23656#comment:3>

Django

unread,
Oct 30, 2014, 3:10:22 AM10/30/14
to django-...@googlegroups.com
#23656: FormMixin.get_form's form_class argument should be optional
--------------------------------------+------------------------------------

Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by charettes):

* needs_better_patch: 1 => 0


Comment:

I think I came up with a decent solution.

If someone overrides `get_form` without defining a default value for
`form_class` a deprecation warning is raised and the unbound method is
wrapped in order to make sure `form_class` defaults to `get_form_class()`
if not provided.

I updated the PR with the POC. I guess we should we also mention this
change in the deprecated section of the release notes?

--
Ticket URL: <https://code.djangoproject.com/ticket/23656#comment:4>

Django

unread,
Oct 30, 2014, 9:40:14 AM10/30/14
to django-...@googlegroups.com
#23656: FormMixin.get_form's form_class argument should be optional
--------------------------------------+------------------------------------

Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by timgraham):

Yes, and of course the deprecation timeline as well.

--
Ticket URL: <https://code.djangoproject.com/ticket/23656#comment:5>

Django

unread,
Oct 30, 2014, 3:47:07 PM10/30/14
to django-...@googlegroups.com
#23656: FormMixin.get_form's form_class argument should be optional
--------------------------------------+------------------------------------

Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by charettes):

Added the missing deprecation note and a mention in the deprecation
timeline.

--
Ticket URL: <https://code.djangoproject.com/ticket/23656#comment:6>

Django

unread,
Oct 30, 2014, 6:58:39 PM10/30/14
to django-...@googlegroups.com
#23656: FormMixin.get_form's form_class argument should be optional
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: master
Component: Generic views | Resolution:
Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/23656#comment:7>

Django

unread,
Oct 30, 2014, 7:11:33 PM10/30/14
to django-...@googlegroups.com
#23656: FormMixin.get_form's form_class argument should be optional
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: master
Component: Generic views | Resolution: fixed

Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette <charette.s@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"f2ddc439b1938acb6cae693bda9d8cf83a4583be"]:
{{{
#!CommitTicketReference repository=""
revision="f2ddc439b1938acb6cae693bda9d8cf83a4583be"
Fixed #23656 -- Made FormMixin.get_form's form_class argument optional.

Thanks Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23656#comment:8>

Django

unread,
Sep 23, 2015, 7:54:46 PM9/23/15
to django-...@googlegroups.com
#23656: FormMixin.get_form's form_class argument should be optional
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: closed
Cleanup/optimization |

Component: Generic views | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"491de4f07c5018aa6f409dbc9bcf32ff631d5f2e" 491de4f0]:
{{{
#!CommitTicketReference repository=""
revision="491de4f07c5018aa6f409dbc9bcf32ff631d5f2e"
Refs #23656 -- Required FormMixin.get_form() form_class parameter to be
optional.

Per deprecation timeline.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23656#comment:9>

Reply all
Reply to author
Forward
0 new messages