https://docs.djangoproject.com/en/dev/topics/auth/
and here:
https://docs.djangoproject.com/en/dev/topics/auth/default/
There is a lot to learn. But for me the core of it is this:
- authentication comes built in by default with simple user objects that include username, password, and email
- if you have a username, a password, and an email address, you can set up a new user using
from django.contrib.auth.models import User >>> user = User.objects.create_user('john', 'lennon@thebeatles.com', 'johnpassword')
- you can check the identity of a user in a view that receives a post request using
from django.contrib.auth import authenticate
username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password)
No comments:
Post a Comment