summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-01-28 14:24:48 +0100
committerClaude Paroz <claude@2xlibre.net>2013-01-28 22:11:00 +0100
commitf7394d2c32b4b4717066f254adaa513d08ab32a4 (patch)
treeae048929e19a7597dae3013abcfe8b371382baa9 /django
parent4f16376274a4e52074722c615fccef5fac5f009a (diff)
Added HTML5 url input type
Refs #16630.
Diffstat (limited to 'django')
-rw-r--r--django/forms/fields.py3
-rw-r--r--django/forms/widgets.py7
2 files changed, 8 insertions, 2 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 8a3dbfeb49..9fbbce107c 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -19,7 +19,7 @@ from django.core import validators
from django.core.exceptions import ValidationError
from django.forms.util import ErrorList, from_current_timezone, to_current_timezone
from django.forms.widgets import (
- TextInput, PasswordInput, EmailInput, HiddenInput,
+ TextInput, PasswordInput, EmailInput, URLInput, HiddenInput,
MultipleHiddenInput, ClearableFileInput, CheckboxInput, Select,
NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput,
SplitDateTimeWidget, SplitHiddenDateTimeWidget, FILE_INPUT_CONTRADICTION
@@ -612,6 +612,7 @@ class ImageField(FileField):
return f
class URLField(CharField):
+ widget = URLInput
default_error_messages = {
'invalid': _('Enter a valid URL.'),
}
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index f201e914dd..e906ed5bc6 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -22,7 +22,8 @@ from django.utils.safestring import mark_safe
from django.utils import datetime_safe, formats, six
__all__ = (
- 'Media', 'MediaDefiningClass', 'Widget', 'TextInput', 'EmailInput', 'PasswordInput',
+ 'Media', 'MediaDefiningClass', 'Widget', 'TextInput',
+ 'EmailInput', 'URLInput', 'PasswordInput',
'HiddenInput', 'MultipleHiddenInput', 'ClearableFileInput',
'FileInput', 'DateInput', 'DateTimeInput', 'TimeInput', 'Textarea', 'CheckboxInput',
'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect',
@@ -255,6 +256,10 @@ class EmailInput(TextInput):
input_type = 'email'
+class URLInput(TextInput):
+ input_type = 'url'
+
+
class PasswordInput(TextInput):
input_type = 'password'