Django

Code

Changeset 4313

Show
Ignore:
Timestamp:
01/12/07 23:19:15 (2 years ago)
Author:
adrian
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/newforms/fields.py

    r4312 r4313  
    289289    def clean(self, value): 
    290290        value = RegexField.clean(self, value) 
     291        if not self.required and value == u'': 
     292            return value 
    291293        if self.verify_exists: 
    292294            import urllib2 
  • django/trunk/tests/regressiontests/forms/tests.py

    r4312 r4313  
    13321332... 
    13331333ValidationError: [u'This URL appears to be a broken link.'] 
     1334>>> f = URLField(verify_exists=True, required=False) 
     1335>>> f.clean('') 
     1336u'' 
     1337>>> f.clean('http://www.google.com') # This will fail if there's no Internet connection 
     1338u'http://www.google.com' 
    13341339 
    13351340EmailField also access min_length and max_length parameters, for convenience.