Please describe what you are trying to achieve
Thank you for making Django-Ninja! I love the developer experience I'm getting out of it, and I find it very accessible and even fun to slowly convert parts of a large Django application to Ninja.
Currently, I'm stuck on the following and would like some help.
I'm trying to accept a partial model as multipart/form-data in a PUT/PATCH request. I'm aware of the middleware workarounds necessary #417 (comment) and I've already added that to my code.
I thought I could combine Form and PatchDict. But this results in a validation error: "data: Field required.". I tried switching the order around PatchDict[Form[DataCreationSchema]] but that didn't work either.
class DataSchema(Schema):
id: int
title: str
description: Optional[str] = None
year: int
class DataCreationSchema(Schema):
title: str
description: Optional[str] = None
year: int
# ...there are other @router.get() requests and @router.post() for retrieval/creation
@router.put("/{id}/", response=DataSchema)
def update_entry(
request,
id: int,
data: Form[PatchDict[DataCreationSchema]], # <--- this doesn't work
):
pass
Is this something that could be implemented/fixed? If it's too complex, please let me know and I'll weigh my options to convert my whole codebase to use application/json instead.
Please describe what you are trying to achieve
Thank you for making Django-Ninja! I love the developer experience I'm getting out of it, and I find it very accessible and even fun to slowly convert parts of a large Django application to Ninja.
Currently, I'm stuck on the following and would like some help.
I'm trying to accept a partial model as
multipart/form-datain a PUT/PATCH request. I'm aware of the middleware workarounds necessary #417 (comment) and I've already added that to my code.I thought I could combine
FormandPatchDict. But this results in a validation error: "data: Field required.". I tried switching the order aroundPatchDict[Form[DataCreationSchema]]but that didn't work either.Is this something that could be implemented/fixed? If it's too complex, please let me know and I'll weigh my options to convert my whole codebase to use
application/jsoninstead.