Django REST Framework-style viewsets for FastAPI, with optional Celery-backed async execution and a Vue/TypeScript client counterpart.
Project description
DynamicForms FastAPI Viewsets
Django REST Framework-style viewsets for FastAPI, with optional Celery-backed async execution and a matching Vue/TypeScript client counterpart.
- Python mixins for FastAPI — compose CRUD and bulk endpoints from small, focused mixin classes.
route_viewsetdecorator — register a viewset on a FastAPI router with a single decorator call. Handles type resolution, lifecycle management and OpenAPI schema automatically.CollectionViewSet— zero-boilerplate in-memory viewset backed by any Python list, set or dict. Great for prototyping and testing.celery_viewsetdecorator — move a viewset's execution to a Celery worker with no code changes to the viewset itself, for long-running or background processing scenarios (requires theceleryextra).- Bulk operations — first-class support for bulk create, update, partial update and destroy.
- Vue / TypeScript counterpart — mirror mixin classes and a
route_restfactory give you a fully typed HTTP client that matches your backend viewset exactly (published separately as@dynamicforms/fastapi-viewsetson npm).
Installation
pip install dynamicforms-fastapi-viewsets
# with Celery-backed viewset support
pip install "dynamicforms-fastapi-viewsets[celery]"
Requires Python 3.10+, FastAPI and Pydantic v2.
Quick example
from fastapi import APIRouter, FastAPI
from pydantic import BaseModel
from fastapi_viewsets.collection_viewset import CollectionViewSet
from fastapi_viewsets.decorators.route_viewset import route_viewset
from fastapi_viewsets.mixins import BulkViewSetMixin
class Item(BaseModel):
id: int
name: str
database: dict[int, Item] = {1: Item(id=1, name="First element")}
app = FastAPI()
router = APIRouter()
@route_viewset(router, base_path="/items", pk_field_name="id")
class ItemViewSet(CollectionViewSet[int, Item], BulkViewSetMixin[int, Item]):
def __init__(self):
super().__init__(container=database, pk_field="id")
app.include_router(router)
See the full documentation for guides on
the mixin system, route_viewset, CollectionViewSet, celery_viewset, and the Vue client.
License
MIT — see LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dynamicforms_fastapi_viewsets-0.3.4.tar.gz.
File metadata
- Download URL: dynamicforms_fastapi_viewsets-0.3.4.tar.gz
- Upload date:
- Size: 36.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f830ee653a9470f62a93c38a1cbbe8dd3fcf13e551504cec9440792243f78a9f
|
|
| MD5 |
5250ef45080fa596bf699d51745a3967
|
|
| BLAKE2b-256 |
74c019866a452fd5996dd26ec9876499ed0e357f0feb99bfe4c85fce78f702c7
|
File details
Details for the file dynamicforms_fastapi_viewsets-0.3.4-py3-none-any.whl.
File metadata
- Download URL: dynamicforms_fastapi_viewsets-0.3.4-py3-none-any.whl
- Upload date:
- Size: 49.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb93b6109e8d8ffe1700e359839133cb32bd59e05ea9e0fcf8ba98a52dd7dbed
|
|
| MD5 |
edd5c9224e5e33ec1d73fc7cb58f269b
|
|
| BLAKE2b-256 |
c5830559e5905550e8772599e88ad7dd6cd8393988a417244a12ae99856df75a
|