我在我的项目中使用 graphql 并希望在注册时生成令牌。尽管 django-graphql-auth 具有所有书面变异,但它使用不同的用户模型。但我想使用我的自定义用户模型。我该怎么办?这是我的用户模型
class CustomUser(AbstractUser):
"""
Customized User Model
"""
email = models.EmailField(blank=True, null=True,
max_length=256, unique=True)
mobile_no = models.CharField(
max_length=20, blank=True, null=True, unique=True)
verification_code = models.CharField(max_length=6)
code_valid_till = models.DateTimeField(blank=True, null=True)
timezone = models.CharField(max_length=40, blank=True, null=True)
country = models.CharField(max_length=20, default='BD', choices=COUNTRIES)
pin_verified = models.BooleanField(default=False)
email_verified = models.BooleanField(default=False)
modified_on = models.DateTimeField('date modified', auto_now=True)
created_on = models.DateTimeField(auto_now_add=True)
# For password reset
reset_verification_code = models.CharField(
max_length=6, blank=True, null=True)
reset_code_valid_till = models.DateTimeField(blank=True, null=True)
reset_request = models.BooleanField(default=False)
reset_valid_till = models.DateTimeField(blank=True, null=True)
class Meta:
verbose_name_plural = "User"
def __str__(self):
if not self.is_anonymous:
return "{} - {}".format(self.mobile_no, self.email)
else:
return "Anon"
@property
def get_full_name(self):
return super().get_full_name()
def get_all_permissions(self, obj=None):
return super().get_all_permissions(obj=obj)
def send_email(self, subject, message, to_email: list, from_email=None, **kwargs):
send_mail_to_user(subject, message, from_email, to_email, **kwargs)