Pydantic models for Django
Djantic
Documentation: https://jordaneremieff.github.io/djantic/
Requirements: Python 3.7+, Django 3.0+
Pydantic models for Django.
This project should be considered a work-in-progress. It should be okay to use, but no specific version support has been determined (#16) and the default model generation behaviour may change across releases.
Please use the issues tracker to report any bugs, or if something seems incorrect.
Quickstart
Install using pip:
pip install djantic
Generating schemas from models
Configure a custom ModelSchema
class for a Django model to generate a Pydantic model. This will allow using the Django model information with Pydantic model methods:
from users.models import User
from djantic import ModelSchema
class UserSchema(ModelSchema):
class Config:
model = User
print(UserSchema.schema())
Output:
{
"title": "UserSchema",
"description": "A user of the application.",