diff options
| author | David Smith <smithdc@gmail.com> | 2020-04-01 17:48:23 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-10 07:11:14 +0200 |
| commit | a350bfa6f44befff8779dbbdd72c9760bf5df959 (patch) | |
| tree | 1bc16fde273533e7566def447a26bfa888b782bc /django/forms | |
| parent | ab903fe304c347e669024ec482832df5f4fd869a (diff) | |
Fixed #13009 -- Added BoundField.widget_type property.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/boundfield.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py index 8832169021..66d065c9c8 100644 --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -1,4 +1,5 @@ import datetime +import re from django.forms.utils import flatatt, pretty_name from django.forms.widgets import Textarea, TextInput @@ -227,6 +228,10 @@ class BoundField: attrs['disabled'] = True return attrs + @property + def widget_type(self): + return re.sub(r'widget$|input$', '', self.field.widget.__class__.__name__.lower()) + @html_safe class BoundWidget: |
