扩展用户模型注意事项

1、AbstractUser

from django.contrib.auth.models import AbstractUser
from django.db import models

# Create your models here.
class MyUser(AbstractUser):
photo = models.CharField('用户头像', max_length=50)
weChat = models.CharField('微信', max_length=30)
level = models.CharField('用户等级', max_length=1)

def __str__(self):
return self.username

 

2、settings.py设置

AUTH_USER_MODEL="users.MyUser"

posted @ 2023-03-22 16:08  侬侬发  阅读(11)  评论(0编辑  收藏  举报