Ticket #5331: urlfield.2.patch
File urlfield.2.patch, 1.7 KB (added by , 17 years ago) |
---|
-
django/newforms/fields.py
405 405 self.user_agent = validator_user_agent 406 406 407 407 def clean(self, value): 408 # If no URL scheme given, assume http:// 409 if value and ':' not in value: 410 value = u'http://%s' % value 408 411 value = super(URLField, self).clean(value) 409 412 if value == u'': 410 413 return value -
tests/regressiontests/forms/tests.py
1589 1589 Traceback (most recent call last): 1590 1590 ... 1591 1591 ValidationError: [u'Enter a valid URL.'] 1592 >>> f.clean('example.com')1593 Traceback (most recent call last):1594 ...1595 ValidationError: [u'Enter a valid URL.']1596 1592 >>> f.clean('http://') 1597 1593 Traceback (most recent call last): 1598 1594 ... … … 1623 1619 Traceback (most recent call last): 1624 1620 ... 1625 1621 ValidationError: [u'Enter a valid URL.'] 1626 >>> f.clean('example.com')1627 Traceback (most recent call last):1628 ...1629 ValidationError: [u'Enter a valid URL.']1630 1622 >>> f.clean('http://') 1631 1623 Traceback (most recent call last): 1632 1624 ... … … 1680 1672 ... 1681 1673 ValidationError: [u'Ensure this value has at most 20 characters (it has 37).'] 1682 1674 1675 URLField should prepend 'http://' if no scheme was given 1676 >>> f = URLField(required=False) 1677 >>> f.clean('example.com') 1678 u'http://example.com' 1679 >>> f.clean('') 1680 u'' 1681 >>> f.clean('https://example.com') 1682 u'https://example.com' 1683 1683 1684 # BooleanField ################################################################ 1684 1685 1685 1686 >>> f = BooleanField()