老师您好 请教一个问题
我自定义admin用户模型,在创建超级用户的时候报错: 'Manager' object has no attribute 'get_by_natural_key'
环境:
python v3.7.5
django v2.2.4
# models.py
from django.db import models from django.contrib.auth.models import AbstractBaseUser class UserProfile(AbstractBaseUser): identifier = models.CharField(max_length=40, unique=True) USERNAME_FIELD = 'identifier' nick_name = models.CharField(max_length=50, verbose_name='昵称', default='') birday = models.DateField(verbose_name='生日', null=True, blank=True) gender = models.CharField(max_length=10, choices=(('male', '男'), ('female', '女')), default='female') address = models.CharField(max_length=100, default='') mobile = models.CharField(max_length=11, null=True, blank=True) image = models.ImageField(upload_to='image/%Y/%m', default='image/default.png', max_length=100) class Meta: verbose_name = '用户信息' verbose_name_plural = verbose_name
你好,请问你这个问题解决了吗?是如何解决的?我也遇到了同样的问题