mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #13009 -- Added BoundField.widget_type property.
This commit is contained in:
parent
ab903fe304
commit
a350bfa6f4
4 changed files with 34 additions and 0 deletions
|
@ -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``
|
||||
-------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue