4👍
✅
to get the the type of the widget in your code use type(field.field.widget)
BoundField
is defined in django.forms
.
0👍
>>> from myapp.forms import RestaurantReviewForm
>>> f = RestaurantReviewForm()
>>> from django.forms.widgets import TextInput
>>> for field in f: print type(field.field.widget), isinstance(field.field.widget, TextInput)
...
<class 'django.forms.widgets.TextInput'> True
<class 'django.forms.widgets.TextInput'> True
<class 'django.forms.widgets.TextInput'> True
<class 'django.forms.widgets.TextInput'> True
<class 'django.forms.widgets.TextInput'> True
<class 'django.forms.widgets.CheckboxInput'> False
<class 'django.forms.widgets.Select'> False
<class 'django.forms.widgets.Textarea'> False
<class 'captcha.fields.CaptchaTextInput'> False
- [Django]-'django.template.context_processors.request' issue with django-tables2 and django-admin-tools
- [Django]-Best practices method of implementing a django OR query from an iterable?
- [Django]-Sending notification to one user using Channels 2
- [Django]-Authentication credentials were not provided django-rest-auth
- [Django]-Django modelform and passing extra parameter
Source:stackexchange.com