Skip to content
New issue

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

Postgres ArrayField in ModelSchema throws KeyError #353

Closed
abdelrahmenAyman opened this issue Feb 9, 2022 · 2 comments
Closed

Postgres ArrayField in ModelSchema throws KeyError #353

abdelrahmenAyman opened this issue Feb 9, 2022 · 2 comments

Comments

@abdelrahmenAyman
Copy link

I have a model Project containing an ArrayField zip_file_urls, this field is imported from django.contrib.postgres.fields.
Then I defined my ProjectSchema as the following:

class ProjectSchema(ModelSchema):
    class Config:
        model = Project
        model_fields = ["project_id", "zip_file_urls"]

Then I use this schema to validate the following endpoint:

@api.post("/projects")
async def create_project(request, project: ProjectSchema):
    return project

When I try to access the docs to try the endpoint it throws a KeyError: ArrayField. My workaround was to remove the zip_file_urls from the model fields, and define a field on the schema zip_file_urls: list[HttpUrl].
Is there something that I am missing that can help me add the field to model_fields normally?

@dhendry
Copy link

dhendry commented Apr 13, 2022

+1 on this, currently hitting the same bug

Love django-ninja BTW, thanks a lot for all the work on it.

@vitalik
Copy link
Owner

vitalik commented Jun 3, 2022

@dhendry @abdelrahmenAyman
fixed in 0.18

@vitalik vitalik closed this as completed Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants