adding html5 field attributes to a model form
I'm trying to edit the field type in a form that is using the html5 doctype. I've tried two ways:
class AddressForm(ModelForm):
contact_email = forms.TextInput(attrs={'type': 'email'})
and
class AddressForm(ModelForm):
def __init__(self, *args, **kwargs):
super(AddressForm, self).__init__(*args, **kwargs)
self.fields['contact_email'].widget.attrs["type"] = 'email'
Neither works.
Am I looking in the wrong place?
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/wpLL-DHz5fQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home