We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug Hello guys, the option exclude_unset=True isn't working for me for some reason:
exclude_unset=True
Versions (please complete the following information):
Here is the snippet code:
class ContractSchemaInput(ModelSchema): sender_id: int client_id: int type_id: int price_frequency: Literal["minute", "hourly", "daily", "weekly", "monthly"] care_type: Literal["ambulante", "accommodation"] attachment_ids: list[str] = [] class Meta: model = Contract exclude = ("id", "type", "sender", "client", "updated", "created") @router.patch("/contracts/{int:id}/update", response=ContractSchema) def update_client_contract(request: HttpRequest, id: int, contract: ContractSchemaInput): print("Payload:", contract.dict(exclude_unset=True)) Contract.objects.filter(id=id).update(**contract.dict(exclude_unset=True)) return get_object_or_404(Contract, id=id)
Output error:
{ "detail": [ { "type": "missing", "loc": [ "body", "contract", "sender_id" ], "msg": "Field required" }, { "type": "missing", "loc": [ "body", "contract", "client_id" ], "msg": "Field required" }, { "type": "missing", "loc": [ "body", "contract", "type_id" ], "msg": "Field required" }, { "type": "missing", "loc": [ "body", "contract", "care_type" ], "msg": "Field required" }, { "type": "missing", "loc": [ "body", "contract", "start_date" ], "msg": "Field required" }, { "type": "missing", "loc": [ "body", "contract", "end_date" ], "msg": "Field required" }, { "type": "missing", "loc": [ "body", "contract", "care_name" ], "msg": "Field required" } ] }
Please any suggestions?
The text was updated successfully, but these errors were encountered:
Your fields are all marked as required, you'll need to set a default to make them not. Basically the opposite of https://docs.pydantic.dev/latest/concepts/models/#field-ordering also https://django-ninja.dev/guides/response/django-pydantic/#making-fields-optional
Sorry, something went wrong.
No branches or pull requests
Describe the bug
Hello guys, the option
exclude_unset=True
isn't working for me for some reason:Versions (please complete the following information):
Here is the snippet code:
Output error:
Please any suggestions?
The text was updated successfully, but these errors were encountered: