Django comes with a user table: Auth_User
To create a user instance:
1.1 , Authenticate ()
Provide user authentication, that is, verify the user name and password is correct, generally need username password two keyword parameters
if certified The information is valid and returns an user object. Authenticate () sets a property on the user object to identify the authenticated backend that authenticated the subscriber, and that information is required during the subsequent logon process. When we try to login a user object that is taken directly from the database without authenticate () will error!!
1 |
user = Authenticate (username= ' someone ', password= ' Somepassword ') |
Auth.login (Request,user) #全局变量 request. User= the current object (session).
As long as Auth.login (Request,user) This statement to write, it means that there is a login user, or an anonymous user, and anonymous user ID, name inside nothing
Python's user authentication component