Kaydet (Commit) f2a3deb0 authored tarafından Adrian Holovaty's avatar Adrian Holovaty

Fixed #3281 -- newforms: URLField now works properly with required=False and…

Fixed #3281 -- newforms: URLField now works properly with required=False and verify_exists=True together. Thanks, zendak

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4313 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 6b31f955
......@@ -288,6 +288,8 @@ class URLField(RegexField):
def clean(self, value):
value = RegexField.clean(self, value)
if not self.required and value == u'':
return value
if self.verify_exists:
import urllib2
from django.conf import settings
......
......@@ -1331,6 +1331,11 @@ ValidationError: [u'This URL appears to be a broken link.']
Traceback (most recent call last):
...
ValidationError: [u'This URL appears to be a broken link.']
>>> f = URLField(verify_exists=True, required=False)
>>> f.clean('')
u''
>>> f.clean('http://www.google.com') # This will fail if there's no Internet connection
u'http://www.google.com'
EmailField also access min_length and max_length parameters, for convenience.
>>> f = URLField(min_length=15, max_length=20)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment