Skip to content

Add pydantic type for validating and deserializing S3FF values #357

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zachmullen
Copy link
Contributor

This library currently provides the s3_file_field.rest_framework.S3FileSerializerField for downstreams to use with Django Rest Framework. However, some downstreams are now using pydantic instead of DRF serializers, e.g. when using django-ninja for REST APIs.

This PR provides the pydantic equivalent serialization helper, to be used by downstreams as follows:

from pydantic import BaseModel
from s3_file_field.pydantic import S3FileFieldValue

class MyModel(BaseModel):
    my_file_field: S3FileFieldValue

When instantiated, this model's my_file_field value will be validated and converted such that it can be passed directly into an S3FileField Django model field.

@zachmullen zachmullen requested a review from brianhelba May 23, 2024 19:27
@zachmullen zachmullen force-pushed the pydantic-serializer branch 3 times, most recently from 669f56e to 66a170d Compare May 23, 2024 20:24
@zachmullen zachmullen force-pushed the pydantic-serializer branch 2 times, most recently from eec495f to d4f7381 Compare July 30, 2025 20:50
@zachmullen zachmullen force-pushed the pydantic-serializer branch from d4f7381 to e78b6c7 Compare July 30, 2025 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs review
Development

Successfully merging this pull request may close these issues.

1 participant