Opened 9 years ago

Closed 9 years ago

#25831 closed Bug (wontfix)

django.views.generic.edit.FormMixinBase : get_form_with_form_class wrapping preventing custom method profiles for get_form()

Reported by: LeGast00n Owned by: nobody
Component: Generic views Version: 1.8
Severity: Normal Keywords: forms views
Cc: Simon Charette Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by LeGast00n)

Hi there,

Django 1.8's FormMixinBase causes an issue for Views that implement a custom method profile for get_form() : the wrapping function tolerates no other argument than form_class.

Current implementation:

                def get_form_with_form_class(self, form_class=None):
                    if form_class is None:
                        form_class = self.get_form_class()
                    return get_form(self, form_class=form_class)

Better implementation:

                def get_form_with_form_class(self, form_class=None, *args, **kwargs):
                    if form_class is None:
                        form_class = self.get_form_class(*args, **kwargs)
                    return get_form(self, form_class=form_class, *args, **kwargs)

cheers

Change History (4)

comment:1 by LeGast00n, 9 years ago

Description: modified (diff)

comment:2 by Tim Graham, 9 years ago

Cc: Simon Charette added

Seems okay to me, although it's a bit late in the 1.8 release cycle to be making this type of change. Is there a reason you can't update your code to avoid the deprecation warning?

comment:3 by Simon Charette, 9 years ago

The suggested implementation makes sense to me except the *arg and **kwargs passing to get_form_class but just like Tim I don't understand why you can't simply change you method signature to accept at least one form_class=None arg.

If you did the method wouldn't be replaced by the shim in the first place.

comment:4 by Tim Graham, 9 years ago

Resolution: wontfix
Status: newclosed

Closing as wontfix pending a stronger justification of why adjusting the deprecation shim is valuable, especially considering it's been 8 months since the release of 1.8 and that version is technically only receiving security fixes and data-loss fixes now.

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