¡Esta es una revisión vieja del documento!
There is only one class in Django which is User, different types of users are instances of this class with other special attributes set.
Main attributes are: username, password, email, first_name, and last_name. However, there are others.
Using create_user function:
from django.contrib.auth.models import User user = User.objects.create_user('john', 'lennon@thebeatles.com', 'johnpassword') # At this point, user is a User object that has already been saved to the database. user.last_name = 'Lennon' user.save()
To change user passwords we'll do:
from django.contrib.auth.models import User u = User.objects.get(username='john') u.set_password('new password') u.save()
User authenticate(), it takes credentials from keyword arguments and returns a User object if they were valid, if not returns None.