Fifteen, django comes with the user's system

django comes with the user's system

 

# Django own user system 
# AUTH_USER tables 
from django.contrib.auth.models Import AbstractUser
 from django.db Import Models 

# user-defined table, a user table inheritance comes AbstractUser 
# configure the setting inside AUTH_USER_MODEL = 'user .MyUser 'path MyUser class 
class MyUser (AbstractUser):   # 
  # need to add additional fields
phone = models.CharField (the verbose_name = ' phone number ' , =. 11 MAX_LENGTH, UNIQUE = True)

 

 

 

Guess you like

Origin www.cnblogs.com/yanyan-/p/11872969.html