-
Let's say I only want to update email. How do I make it so I don't have to post other fields? |
Beta Was this translation helpful? Give feedback.
Answered by
Lodimup
Sep 28, 2023
Replies: 2 comments 2 replies
-
Somebody that found a solution on how to do this? |
Beta Was this translation helpful? Give feedback.
2 replies
-
If you want to make it work with from typing import Any
from ninja import Schema
class User(Schema):
first_name: str
last_name: str
age: int
address: str
class OptionalSchema(Schema):
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
super().__pydantic_init_subclass__(**kwargs)
for field in cls.model_fields.values():
field.default = None
cls.model_rebuild(force=True)
class PartialUser(User, OptionalSchema):
... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://django-ninja.rest-framework.com/guides/response/django-pydantic/
here, under Making fields optional
It's implemented on May 28
@vitalik vitalik
v0.22.0
9c6f136
0.22.0