#10908 closed (fixed)
Information about proper way of user creation for testing
Reported by: | Filip Gruszczyński | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have created user using User.objects.create and then tried Client().login and it constantly fails. The proper way was to user User.objects.create_user, but there was not a word in testing docs! There should be such information. Here is the link: http://docs.djangoproject.com/en/dev/topics/testing/#django.test.client.Client.login
Attachments (2)
Change History (10)
comment:1 by , 16 years ago
Component: | Uncategorized → Documentation |
---|
follow-up: 3 comment:2 by , 16 years ago
comment:3 by , 16 years ago
+1. I had this problem recently as well. I think the issue is that using create() doesn't hash the password. I had to use set_password() until I discovered create_user().
comment:4 by , 16 years ago
I don't know, if it's useful, but I have written this additional line and I am uploading diff.
by , 16 years ago
Attachment: | docs.patch added |
---|
comment:5 by , 16 years ago
Has patch: | set |
---|
comment:6 by , 15 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|---|
Version: | 1.0 → SVN |
comment:7 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Replying to gruszczy:
Are you sure you are correctly using
create()
? This test shows an user can be created without having to resort to usecreate_user()
and the documentation says it is "The most basic way" not that it is the proper or exclusive way to add an user.