--- id: djangorestframework-dataclasses version: "1.4.0" license: Copyright (c) 2019-2021, Oxan van Leeuwen Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.… (full text in the JSON record) license_treatment: permissive maintenance: aging --- # djangorestframework-dataclasses — A dataclasses serializer for Django REST Framework License: permissive · Maintenance: aging · Downloads: 2.8M/mo ## What it is and what it does This package provides a DataclassSerializer that automatically generates Django REST Framework serializer fields from dataclass type annotations. Instead of manually declaring each field twice—once in the dataclass and again in a DRF Serializer—you define the dataclass with type hints and let the serializer introspect it. The package handles common Python types (str, bool, int, float, date, datetime, time, timedelta, Decimal, UUID, Enum, Literal, Union, Iterable, Mapping) and generates corresponding REST Framework fields, respecting optional fields, nullable types, and read-only markers. It follows the ModelSerializer pattern familiar to Django developers: you specify the dataclass in a Meta subclass, optionally override or add fields, and get create() and update() implementations for free. The serializer works with the standard DRF workflow—calling .data for serialized output, .validated_data for deserialized instances, and save() to persist or update objects. This is most useful in projects that use dataclasses for domain models or DTOs rather than Django ORM models. Use it for: - Serialize and deserialize dataclass-based domain models in REST APIs without duplicating field definitions. - Build REST endpoints that accept and return typed dataclass instances instead of raw dictionaries. - Reduce boilerplate when working with dataclasses as request/response DTOs in Django views or viewsets. - Automatically validate incoming data against dataclass type annotations and constraints. - Migrate from ModelSerializer-based APIs to dataclass-based architectures with minimal refactoring. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Automatically generates Django REST Framework serializers from Python dataclasses, mapping dataclass fields to REST serializer fields without manual duplication. Yes, if you use dataclasses as your primary data model layer in Django REST Framework projects. The package is stable and permissively licensed, with low install friction. The 457-day release gap suggests slower maintenance, so verify compatibility with your Django and DRF versions before adopting; otherwise it is a solid fit for eliminating serializer boilerplate. ## Install pip install djangorestframework-dataclasses uv add djangorestframework-dataclasses poetry add djangorestframework-dataclasses ## Installing djangorestframework-dataclasses Before you install: Low friction install with three straightforward runtime dependencies (django, djangorestframework, typing_extensions). Maintenance status is aging—last release was 457 days ago—but the repository remains active and marked Production/Stable. License in practice: BSD-3-clause license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions. Quickstart: pip install djangorestframework-dataclasses from dataclasses import dataclass from djangorestframework_dataclasses.serializers import DataclassSerializer @dataclass class Person: name: str email: str class PersonSerializer(DataclassSerializer): class Meta: dataclass = Person Requires Django 3.2+ and Django REST Framework 3.11+; Python 3.7+ (description lists 3.8+ as tested minimum). Verify before relying: - Whether the 457-day gap since last release indicates active maintenance or dormancy relative to Django/DRF release cycles. - Support status for the latest versions of Django and Django REST Framework beyond what the description guarantees. - Full scope of type annotations supported beyond str, bool, int, float, date, datetime, time, timedelta, Decimal, UUID, Enum, Iterable, Mapping, Literal, Union, and django.db.Model. ## Package facts - License: Copyright (c) 2019-2021, Oxan van Leeuwen Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 2.8M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags dataclass serializer django rest framework, automatic serializer generation dataclasses, django rest framework dataclass support, serialize dataclasses drf, dataclass to rest serializer, django dataclass serialization, django-rest-framework, dataclass-serialization, api-development [View on SkillFed](https://skillfed.io/packages/djangorestframework-dataclasses) · [View on PyPI](https://pypi.org/project/djangorestframework-dataclasses/)