user/models.py创建模型:从写django user表
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser):
phone = models.CharField('手机号',max_length=20)
img = models.ImageField(upload_to='user',null=True)
nick_name = models.CharField('昵称',max_length=20)
address = models.CharField('地址',max_length=255)
class Meta:
db_table = 'tb_user'
syl/settings.py中注册自己的用户模型类
# 注册自己的用户模型类: 应用名.模型名,指定我们重写的User表进行身份验证
AUTH_USER_MODEL = 'user.User'
配置mysql
'''1.创建mysql数据库'''
mysql> create database syldb charset utf8;
生成表
python manager.py makemigrations
python manager.py migrate