1、用户认证组件
用户认证组件:
功能:用session记录登录验证状态
前提:用户表:django自带的auth_user
创建超级用户: python3 manage.py createsuperuser
创建超级用户
C:\PycharmProjects\authdemo>python manage.py createsuperuser Username (leave blank to use 'venicid'): alex Email address: # 空 Password: 1234 Password (again): This password is too short. It must contain at least 8 characters. This password is entirely numeric. Password: 12345678 Password (again): This password is too common. This password is entirely numeric. Password: qwerasdf Password (again): Superuser created successfully.
不能像一般取数据库中的数据,密码是密文的
2、auth模块详细代码
from django.contrib import auth #django.contrib.auth中提供了许多方法,这里主要介绍其中的三个:
创建超级用户
C:\PycharmProjects\authdemo>python manage.py createsuperuser Username (leave blank to use 'venicid'): alex Email address: # 空 Password: 1234 Password (again): This password is too short. It must contain at least 8 characters. This password is entirely numeric. Password: 12345678 Password (again): This password is too common. This password is entirely numeric. Password: qwerasdf Password (again): Superuser created successfully.