equal
deleted
inserted
replaced
19 [u'A user with that username already exists.'] |
19 [u'A user with that username already exists.'] |
20 |
20 |
21 # The username contains invalid data. |
21 # The username contains invalid data. |
22 |
22 |
23 >>> data = { |
23 >>> data = { |
24 ... 'username': 'jsmith@example.com', |
24 ... 'username': 'jsmith!', |
25 ... 'password1': 'test123', |
25 ... 'password1': 'test123', |
26 ... 'password2': 'test123', |
26 ... 'password2': 'test123', |
27 ... } |
27 ... } |
28 >>> form = UserCreationForm(data) |
28 >>> form = UserCreationForm(data) |
29 >>> form.is_valid() |
29 >>> form.is_valid() |
30 False |
30 False |
31 >>> form["username"].errors |
31 >>> form["username"].errors |
32 [u'This value must contain only letters, numbers and underscores.'] |
32 [u'This value may contain only letters, numbers and @/./+/-/_ characters.'] |
33 |
33 |
34 # The verification password is incorrect. |
34 # The verification password is incorrect. |
35 |
35 |
36 >>> data = { |
36 >>> data = { |
37 ... 'username': 'jsmith2', |
37 ... 'username': 'jsmith2', |
63 [u'This field is required.'] |
63 [u'This field is required.'] |
64 |
64 |
65 # The success case. |
65 # The success case. |
66 |
66 |
67 >>> data = { |
67 >>> data = { |
68 ... 'username': 'jsmith2', |
68 ... 'username': 'jsmith2@example.com', |
69 ... 'password1': 'test123', |
69 ... 'password1': 'test123', |
70 ... 'password2': 'test123', |
70 ... 'password2': 'test123', |
71 ... } |
71 ... } |
72 >>> form = UserCreationForm(data) |
72 >>> form = UserCreationForm(data) |
73 >>> form.is_valid() |
73 >>> form.is_valid() |
74 True |
74 True |
75 >>> form.save() |
75 >>> form.save() |
76 <User: jsmith2> |
76 <User: jsmith2@example.com> |
77 |
77 |
78 # The user submits an invalid username. |
78 # The user submits an invalid username. |
79 |
79 |
80 >>> data = { |
80 >>> data = { |
81 ... 'username': 'jsmith_does_not_exist', |
81 ... 'username': 'jsmith_does_not_exist', |
187 >>> data = {'username': 'not valid'} |
187 >>> data = {'username': 'not valid'} |
188 >>> form = UserChangeForm(data, instance=user) |
188 >>> form = UserChangeForm(data, instance=user) |
189 >>> form.is_valid() |
189 >>> form.is_valid() |
190 False |
190 False |
191 >>> form['username'].errors |
191 >>> form['username'].errors |
192 [u'This value must contain only letters, numbers and underscores.'] |
192 [u'This value may contain only letters, numbers and @/./+/-/_ characters.'] |
193 |
193 |
194 |
194 |
195 ### PasswordResetForm |
195 ### PasswordResetForm |
196 |
196 |
197 >>> from django.contrib.auth.forms import PasswordResetForm |
197 >>> from django.contrib.auth.forms import PasswordResetForm |
217 >>> form.is_valid() |
217 >>> form.is_valid() |
218 True |
218 True |
219 >>> form.cleaned_data['email'] |
219 >>> form.cleaned_data['email'] |
220 u'jsmith3@example.com' |
220 u'jsmith3@example.com' |
221 |
221 |
|
222 # bug #5605, preserve the case of the user name (before the @ in the email address) |
|
223 # when creating a user. |
|
224 >>> user = User.objects.create_user('forms_test2', 'tesT@EXAMple.com', 'test') |
|
225 >>> user.email |
|
226 'tesT@example.com' |
|
227 >>> user = User.objects.create_user('forms_test3', 'tesT', 'test') |
|
228 >>> user.email |
|
229 'tesT' |
|
230 |
222 """ |
231 """ |