Using the example
1. Create a user
>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user (' John ', ' [email protected] ', ' Johnpassword ')
# at the this point, user was a user object that has already been saved
# to the database. You can continue to the change of its attributes
# If you want to the change of other fields.
>>> User.is_staff = True
>>> User.save ()
2. Change the password
>>> from django.contrib.auth.models import User
>>> u = User.objects.get (username__exact= ' John ')
>>> u.set_password (' New password ')
>>> U.save ()
Create a Super Administrator
manage.py createsuperuser--username=joe [email protected]
Front End effect:
Resources:
The users permission system in Django: http://blog.chinaunix.net/uid-25525723-id-331051.html
self-made Change Password page, automatically eject something unwanted : http://mozilla.com.cn/thread-329027-1-1.html
How does the "Python" Django auth change the password?