Skip to content

Commit d09bc97

Browse files
committed
Switched to ModelSchema to avoid extra import
1 parent 67716a3 commit d09bc97

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ninja_jwt/schema.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
from django.contrib.auth import authenticate, get_user_model
55
from django.contrib.auth.models import AbstractUser, update_last_login
66
from django.utils.translation import gettext_lazy as _
7-
from ninja.orm import create_schema
8-
from ninja_jwt.utils import token_error
97
from ninja_schema import ModelSchema, Schema
108
from pydantic import root_validator
119

10+
from ninja_jwt.utils import token_error
11+
1212
from . import exceptions
1313
from .settings import api_settings
1414
from .tokens import RefreshToken, SlidingToken, Token, UntypedToken
@@ -19,7 +19,10 @@
1919
user_name_field = get_user_model().USERNAME_FIELD # type: ignore
2020

2121

22-
AuthUserSchema = create_schema(get_user_model(), fields=[user_name_field])
22+
class AuthUserSchema(ModelSchema):
23+
class Config:
24+
model = get_user_model()
25+
include = [user_name_field]
2326

2427

2528
class TokenObtainSerializer(ModelSchema):

0 commit comments

Comments
 (0)