diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py index ad357117c3..6223129786 100644 --- a/django/views/generic/edit.py +++ b/django/views/generic/edit.py @@ -1,11 +1,6 @@ -import inspect -import warnings - from django.core.exceptions import ImproperlyConfigured from django.forms import models as model_forms from django.http import HttpResponseRedirect -from django.utils import six -from django.utils.deprecation import RemovedInDjango110Warning from django.utils.encoding import force_text from django.views.generic.base import ContextMixin, TemplateResponseMixin, View from django.views.generic.detail import ( @@ -13,28 +8,7 @@ from django.views.generic.detail import ( ) -class FormMixinBase(type): - def __new__(cls, name, bases, attrs): - get_form = attrs.get('get_form') - if get_form and inspect.isfunction(get_form): - try: - inspect.getcallargs(get_form, None) - except TypeError: - warnings.warn( - "`%s.%s.get_form` method must define a default value for " - "its `form_class` argument." % (attrs['__module__'], name), - RemovedInDjango110Warning, stacklevel=2 - ) - - 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) - attrs['get_form'] = get_form_with_form_class - return super(FormMixinBase, cls).__new__(cls, name, bases, attrs) - - -class FormMixin(six.with_metaclass(FormMixinBase, ContextMixin)): +class FormMixin(ContextMixin): """ A mixin that provides a way to show and handle a form in a request. """ diff --git a/docs/ref/class-based-views/mixins-editing.txt b/docs/ref/class-based-views/mixins-editing.txt index ed13257747..832f42ccd4 100644 --- a/docs/ref/class-based-views/mixins-editing.txt +++ b/docs/ref/class-based-views/mixins-editing.txt @@ -59,10 +59,6 @@ FormMixin :meth:`~django.views.generic.edit.FormMixin.get_form_kwargs`. If ``form_class`` isn't provided :meth:`get_form_class` will be used. - .. versionchanged:: 1.8 - - The ``form_class`` argument is not required anymore. - .. method:: get_form_kwargs() Build the keyword arguments required to instantiate the form. diff --git a/tests/generic_views/test_edit.py b/tests/generic_views/test_edit.py index 669a70639d..a6ad397a48 100644 --- a/tests/generic_views/test_edit.py +++ b/tests/generic_views/test_edit.py @@ -1,13 +1,10 @@ from __future__ import unicode_literals -import warnings - from django import forms from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import reverse from django.test import SimpleTestCase, TestCase, override_settings from django.test.client import RequestFactory -from django.utils.deprecation import RemovedInDjango110Warning from django.views.generic.base import View from django.views.generic.edit import CreateView, FormMixin, ModelFormMixin @@ -59,28 +56,6 @@ class FormMixinTests(SimpleTestCase): 'get_form() should fallback to get_form_class() if none is provided.' ) - def test_get_form_missing_form_class_default_value(self): - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings('always') - - class MissingDefaultValue(FormMixin): - request = RequestFactory().get('/') - form_class = forms.Form - - def get_form(self, form_class): - return form_class(**self.get_form_kwargs()) - self.assertEqual(len(w), 1) - self.assertEqual(w[0].category, RemovedInDjango110Warning) - self.assertEqual( - str(w[0].message), - '`generic_views.test_edit.MissingDefaultValue.get_form` method ' - 'must define a default value for its `form_class` argument.' - ) - - self.assertIsInstance( - MissingDefaultValue().get_form(), forms.Form, - ) - def test_get_context_data(self): class FormContext(FormMixin): request = RequestFactory().get('/')