Skip to main content


Say for example you want to modify the output schema once the user logs in in your app my_app to only display specific fields. In your, you can create the following:
from django.contrib.auth import authenticate, get_user_model
from dj_ninja_auth.schema import SuccessMessageMixin, LoginInputSchema

UserModel = get_user_model()

class MyAuthUserSchema(ModelSchema):
class Meta:
model = UserModel
fields = ['id', 'username', 'first_name', 'last_name']

class MyLoginOutputSchema(SuccessMessageMixin):
user: MyAuthUserSchema
my_other_value: str

class MyLoginInputSchema(LoginInputSchema):
def get_response_schema(cls) -> Type[Schema]:
return MyLoginOutputSchema

def to_response_schema(self, **kwargs):
return super().to_response_schema(my_other_value="foo", **kwargs)

Then in your, you can specify:
NINJA_AUTH_LOGIN_INPUT_SCHEMA = "my_app.schema.MyLoginInputSchema"