django 3.xx 扩展User表
1. 导入 django user 表继承类 :AbstractUser
from django.db import models # Create your models here. #引入django自带的user表,方便下方继承 from django.contrib.auth.models import AbstractUser #继承 AbstractUser class User(AbstractUser): #在下方添加所扩展的字段 usertype = models.PositiveIntegerField(null=True,blank=True,verbose_name="用户类型") realname = models.CharField(max_length=100,null=True,blank=True,verbose_name="用户名")
2.再在 settings.py 里面添加
AUTH_USER_MODEL =‘app.User‘然后执行
python manage.py makemigrations app
python manage.py migrate 就可以
然后,后面就只能用你新建的表了