Is it possible to make django's (v1.2) URLField output an HTML5 input tag where type="url"?
------------- SOLUTION -------------
from django.forms import ModelForm
from django.forms import widgets
from django.forms import fields
from models import MyObj
class URLInput(widgets.Input):
input_type = 'url'
class MyObjForm(ModelForm):
url = fields.URLField(widget=URLInput())
class Meta:
model = MyObj
You have to create a custom widget for that.
class URLInput(forms.TextInput):
input_type = 'url'
Then you can pass this widget to URLField constructor:
class MyForm(forms.Form):
url = forms.URLField(widget=URLInput())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With