Fixed #13009 -- Added BoundField.widget_type property.

This commit is contained in:
David Smith 2020-04-01 17:48:23 +01:00 committed by Mariusz Felisiak
parent ab903fe304
commit a350bfa6f4
4 changed files with 34 additions and 0 deletions

View file

@ -972,6 +972,23 @@ Attributes of ``BoundField``
>>> print(f['message'].name)
message
.. attribute:: BoundField.widget_type
.. versionadded:: 3.1
Returns the lowercased class name of the wrapped field's widget, with any
trailing ``input`` or ``widget`` removed. This may be used when building
forms where the layout is dependent upon the widget type. For example::
{% for field in form %}
{% if field.widget_type == 'checkbox' %}
# render one way
{% else %}
# render another way
{% endif %}
{% endfor %}
Methods of ``BoundField``
-------------------------