mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #13009 -- Added BoundField.widget_type property.
This commit is contained in:
committed by
Mariusz Felisiak
parent
ab903fe304
commit
a350bfa6f4
@@ -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``
|
||||
-------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user