mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
queryset-refactor: Merged to [6190]
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6334 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1623,10 +1623,6 @@ u'http://200.8.9.10:8000/test'
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a valid URL.']
|
||||
>>> f.clean('example.com')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a valid URL.']
|
||||
>>> f.clean('http://')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
@@ -1657,10 +1653,6 @@ u'http://www.example.com'
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a valid URL.']
|
||||
>>> f.clean('example.com')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a valid URL.']
|
||||
>>> f.clean('http://')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
@@ -1714,6 +1706,15 @@ Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Ensure this value has at most 20 characters (it has 37).']
|
||||
|
||||
URLField should prepend 'http://' if no scheme was given
|
||||
>>> f = URLField(required=False)
|
||||
>>> f.clean('example.com')
|
||||
u'http://example.com'
|
||||
>>> f.clean('')
|
||||
u''
|
||||
>>> f.clean('https://example.com')
|
||||
u'https://example.com'
|
||||
|
||||
# BooleanField ################################################################
|
||||
|
||||
>>> f = BooleanField()
|
||||
@@ -2690,16 +2691,24 @@ to the next.
|
||||
... super(Person, self).__init__(*args, **kwargs)
|
||||
... if names_required:
|
||||
... self.fields['first_name'].required = True
|
||||
... self.fields['first_name'].widget.attrs['class'] = 'required'
|
||||
... self.fields['last_name'].required = True
|
||||
... self.fields['last_name'].widget.attrs['class'] = 'required'
|
||||
>>> f = Person(names_required=False)
|
||||
>>> f['first_name'].field.required, f['last_name'].field.required
|
||||
(False, False)
|
||||
>>> f['first_name'].field.widget.attrs, f['last_name'].field.widget.attrs
|
||||
({}, {})
|
||||
>>> f = Person(names_required=True)
|
||||
>>> f['first_name'].field.required, f['last_name'].field.required
|
||||
(True, True)
|
||||
>>> f['first_name'].field.widget.attrs, f['last_name'].field.widget.attrs
|
||||
({'class': 'required'}, {'class': 'required'})
|
||||
>>> f = Person(names_required=False)
|
||||
>>> f['first_name'].field.required, f['last_name'].field.required
|
||||
(False, False)
|
||||
>>> f['first_name'].field.widget.attrs, f['last_name'].field.widget.attrs
|
||||
({}, {})
|
||||
>>> class Person(Form):
|
||||
... first_name = CharField(max_length=30)
|
||||
... last_name = CharField(max_length=30)
|
||||
|
||||
Reference in New Issue
Block a user