From d09bc97dadc919fb8727af35638e97ea34d64072 Mon Sep 17 00:00:00 2001 From: Pavel Date: Sat, 19 Mar 2022 15:35:34 -0400 Subject: [PATCH] Switched to ModelSchema to avoid extra import --- ninja_jwt/schema.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ninja_jwt/schema.py b/ninja_jwt/schema.py index f65d82736..6e8ad72ab 100644 --- a/ninja_jwt/schema.py +++ b/ninja_jwt/schema.py @@ -4,11 +4,11 @@ from django.contrib.auth import authenticate, get_user_model from django.contrib.auth.models import AbstractUser, update_last_login from django.utils.translation import gettext_lazy as _ -from ninja.orm import create_schema -from ninja_jwt.utils import token_error from ninja_schema import ModelSchema, Schema from pydantic import root_validator +from ninja_jwt.utils import token_error + from . import exceptions from .settings import api_settings from .tokens import RefreshToken, SlidingToken, Token, UntypedToken @@ -19,7 +19,10 @@ user_name_field = get_user_model().USERNAME_FIELD # type: ignore -AuthUserSchema = create_schema(get_user_model(), fields=[user_name_field]) +class AuthUserSchema(ModelSchema): + class Config: + model = get_user_model() + include = [user_name_field] class TokenObtainSerializer(ModelSchema):