Removed legacy password_md5 stuff from docs/authentication.txt
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2587 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b353103cb6
commit
66e04858eb
|
@ -137,25 +137,16 @@ Basic usage
|
||||||
Creating users
|
Creating users
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
The most basic way to create users is to use the standard Django
|
The most basic way to create users is to use the ``create_user`` helper
|
||||||
`database API`_. Just create and save a ``User`` object::
|
function that comes with Django::
|
||||||
|
|
||||||
>>> from django.models.auth import users
|
>>> from django.models.auth import users
|
||||||
>>> import md5
|
>>> user = users.create_user('john', 'lennon@thebeatles.com', 'johnpassword')
|
||||||
>>> p = md5.new('johnpassword').hexdigest()
|
|
||||||
>>> u = users.User(username='john', first_name='John', last_name='lennon',
|
|
||||||
... email='lennon@thebeatles.com', password_md5=p, is_staff=True,
|
|
||||||
... is_active=True, is_superuser=False)
|
|
||||||
>>> u.save()
|
|
||||||
|
|
||||||
Note that ``password_md5`` requires the raw MD5 hash (as created by
|
# Now, user is a User object already saved to the database.
|
||||||
``md5.new().hexdigest()``). Because that's a pain, there's a ``create_user``
|
# You can continue to change its attributes if you want to change other fields.
|
||||||
helper function::
|
>>> user.is_staff = True
|
||||||
|
>>> user.save()
|
||||||
>>> from django.models.auth import users
|
|
||||||
>>> u = users.create_user('john', 'lennon@thebeatles.com', 'johnpassword')
|
|
||||||
|
|
||||||
.. _database API: http://www.djangoproject.com/documentation/db_api/
|
|
||||||
|
|
||||||
Changing passwords
|
Changing passwords
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -167,6 +158,9 @@ Change a password with ``set_password()``::
|
||||||
>>> u.set_password('new password')
|
>>> u.set_password('new password')
|
||||||
>>> u.save()
|
>>> u.save()
|
||||||
|
|
||||||
|
Don't set the password field directly unless you know what you're doing. This
|
||||||
|
is explained in the next section.
|
||||||
|
|
||||||
Passwords
|
Passwords
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue