from django.db import models from django.contrib.auth.models import AbstractBaseUser, BaseUserManager import uuid class User(AbstractBaseUser): 补全代码
时间: 2023-11-24 15:07:07 浏览: 121
class User(AbstractBaseUser):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
email = models.EmailField(unique=True)
username = models.CharField(max_length=255, unique=True)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField(default=False)
date_joined = models.DateTimeField(auto_now_add=True)
# ... other fields and methods
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username']
objects = UserManager()
def __str__(self):
return self.email
def has_perm(self, perm, obj=None):
return True
def has_module_perms(self, app_label):
return True
@property
def is_superuser(self):
return self.is_staff
class Meta:
verbose_name = 'user'
verbose_name_plural = 'users'
阅读全文