小编Isi*_*sco的帖子

断言错误:您需要在 UserProfile.Meta 中传递有效的 Django 模型,收到“无”

我正在使用 AbstractBaseUser 自定义用户模型将 Django 模型添加到 graphql api。管理员工作正常,但我在尝试访问 graphql api 时收到错误消息,“您需要在 UserProfile.Meta 中传递有效的 Django 模型,收到“无””

我已经尝试将 AUTH_USER_MODEL = 'noxer_app.MyUser' 添加到设置中,但它不起作用

在models.py中:

from django.db import models
from django.contrib.auth.models import (
    BaseUserManager, AbstractBaseUser
)


class MyUserManager(BaseUserManager):
    def create_user(self, email, first_name, last_name, company, company_reg_no, address, phone, image, password=None):

        if not email:
            raise ValueError('Users must have an email address')

        user = self.model(
            email=self.normalize_email(email),
            first_name=first_name,
            last_name=last_name,
            company=company,
            company_reg_no=company_reg_no,
            address=address,
            phone=phone,
            image=image,
        )

        user.set_password(password)
        user.save(using=self._db)
        return user

    def create_superuser(self, email, first_name, last_name, company, company_reg_no, address, phone, image, …
Run Code Online (Sandbox Code Playgroud)

django graphene-django

0
推荐指数
1
解决办法
897
查看次数

标签 统计

django ×1

graphene-django ×1