diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py index 83944422ff3..6acae1c59b7 100644 --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -1,12 +1,9 @@ import datetime -import warnings from django.forms.utils import flatatt, pretty_name from django.forms.widgets import Textarea, TextInput -from django.utils.deprecation import RemovedInDjango21Warning from django.utils.functional import cached_property from django.utils.html import conditional_escape, format_html, html_safe -from django.utils.inspect import func_accepts_kwargs, func_supports_parameter from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ @@ -102,20 +99,11 @@ class BoundField: else: name = self.html_initial_name - kwargs = {} - if func_supports_parameter(widget.render, 'renderer') or func_accepts_kwargs(widget.render): - kwargs['renderer'] = self.form.renderer - else: - warnings.warn( - 'Add the `renderer` argument to the render() method of %s. ' - 'It will be mandatory in Django 2.1.' % widget.__class__, - RemovedInDjango21Warning, stacklevel=2, - ) return widget.render( name=name, value=self.value(), attrs=attrs, - **kwargs + renderer=self.form.renderer, ) def as_text(self, attrs=None, **kwargs): diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt index 1dc57a1f7ef..9fad3c69f5d 100644 --- a/docs/ref/forms/widgets.txt +++ b/docs/ref/forms/widgets.txt @@ -274,11 +274,6 @@ foundation for custom widgets. ``None``, the renderer from the :setting:`FORM_RENDERER` setting is used. - .. versionchanged:: 1.11 - - The ``renderer`` argument was added. Support for subclasses that - don't accept it will be removed in Django 2.1. - .. method:: value_from_datadict(data, files, name) Given a dictionary of data and this widget's name, returns the value diff --git a/docs/releases/2.1.txt b/docs/releases/2.1.txt index d4dbc8fc3aa..55dfb09ea95 100644 --- a/docs/releases/2.1.txt +++ b/docs/releases/2.1.txt @@ -258,3 +258,6 @@ how to remove usage of these features. * The ``Model._meta.has_auto_field`` attribute is removed. * Support for regular expression groups with ``iLmsu#`` in ``url()`` is removed. + +* Support for ``Widget.render()`` methods without the ``renderer`` argument + is removed. diff --git a/tests/forms_tests/widget_tests/test_render_deprecation.py b/tests/forms_tests/widget_tests/test_render_deprecation.py deleted file mode 100644 index 4059f043e3d..00000000000 --- a/tests/forms_tests/widget_tests/test_render_deprecation.py +++ /dev/null @@ -1,35 +0,0 @@ -from django import forms -from django.test import SimpleTestCase -from django.utils.deprecation import RemovedInDjango21Warning - - -class RenderDeprecationTests(SimpleTestCase): - def test_custom_widget_renderer_warning(self): - class CustomWidget1(forms.TextInput): - def render(self, name, value, attrs=None, renderer=None): - return super().render(name, value, attrs, renderer) - - class CustomWidget2(forms.TextInput): - def render(self, *args, **kwargs): - return super().render(*args, **kwargs) - - class CustomWidget3(forms.TextInput): - def render(self, name, value, attrs=None): - return super().render(name, value, attrs) - - class MyForm(forms.Form): - foo = forms.CharField(widget=CustomWidget1) - bar = forms.CharField(widget=CustomWidget2) - baz = forms.CharField(widget=CustomWidget3) - - form = MyForm() - str(form['foo']) # No warning. - str(form['bar']) # No warning. - msg = ( - "Add the `renderer` argument to the render() method of " - ".CustomWidget3'>. It will be mandatory in Django 2.1." - ) - with self.assertRaisesMessage(RemovedInDjango21Warning, msg): - str(form['baz'])