标签:guard date erb imp 利用 res The static phone
内置User类
使用内置User可以方便实现登录验证,利用Admin管理界面还可以方便添加、删除、修改用户。
from django.db import models from django.contrib.auth.models import AbstractUser # 添加电话字段 class UserInfo(AbstractUser): phone = models.CharField(null=True, max_length=20, verbose_name=‘电话‘, default=‘‘) class Meta: pass
3. 修改Settings.py
INSTALLED_APPS = [ ‘django.contrib.admin‘, ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.messages‘, ‘django.contrib.staticfiles‘, ‘guardian‘, ‘homepage‘, ‘rest_framework‘, ‘rest_framework.authtoken‘, # TokenAuthentication ‘user‘, # 添加user应用 ‘stock‘, ‘future‘, ‘api‘, ‘perm‘ ] # 设置AUTH_USER_MODEL AUTH_USER_MODEL = ‘user.UserInfo‘
标签:guard date erb imp 利用 res The static phone
原文地址:https://www.cnblogs.com/bryant24/p/11445354.html