Author: adrian
Date: 2007-01-12 23:19:15 -0600 (Fri, 12 Jan 2007)
New Revision: 4313
Modified:
django/trunk/django/newforms/fields.py
django/trunk/tests/regressiontests/forms/tests.py
Log:
Fixed #3281 -- newforms: URLField now works properly with required=False and
verify_exists=True together. Thanks, zendak
Modified: django/trunk/django/newforms/fields.py
===================================================================
--- django/trunk/django/newforms/fields.py 2007-01-13 05:08:07 UTC (rev
4312)
+++ django/trunk/django/newforms/fields.py 2007-01-13 05:19:15 UTC (rev
4313)
@@ -288,6 +288,8 @@
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
Modified: django/trunk/tests/regressiontests/forms/tests.py
===================================================================
--- django/trunk/tests/regressiontests/forms/tests.py 2007-01-13 05:08:07 UTC
(rev 4312)
+++ django/trunk/tests/regressiontests/forms/tests.py 2007-01-13 05:19:15 UTC
(rev 4313)
@@ -1331,6 +1331,11 @@
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)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---