No Boilerplate, just rapid Django API ⚡️
Write powerful Django APIs with minimal code. Djapy combines Django's robustness with modern API development practices, giving you a clean, intuitive way to build REST APIs.
@djapify
def get_user(request, username: str) -> UserSchema:
return User.objects.get(username=username)
That's it. No serializers, no viewsets, no boilerplate - just pure Python.
✨ Why Djapy?
Write Django REST APIs that are simple by default, powerful when needed. Djapy works seamlessly with Django's ecosystem while adding modern API features.
# Works perfectly with Django decorators
@cache_page(BASIC_CACHE_1_HOUR)
@djapify
def get_posts(request, search: Optional[str] = None) -> List[PostSchema]:
posts = Post.objects.all()
if search:
posts = posts.filter(title__icontains=search)
return posts
# Need async? Just use async_djapify
@async_djapify
@paginate
async def get_comments(request, post_id: int) -> List[CommentSchema]:
return await Comment.objects.filter(post_id=post_id).aall()
🚀 Key Features
- Zero Boilerplate: Build APIs with pure Python
- Django Native: Works seamlessly with Django's decorators and features
- Type Safety: Full Python type hints with Pydantic
- Async When You Need It: Optional async support for high-performance endpoints
- Smart Authentication: Simple session auth, customizable when needed
- OpenAPI Support: Automatic Swagger documentation
- IDE Friendly: Full intellisense support
🎯 Quick Start
- Install Djapy
pip install djapy
- Create Your First API
from djapy import djapify, Schema
class PostSchema(Schema):
title: str
body: str
author: str
@djapify
def create_post(request, data: PostSchema) -> {201: PostSchema}:
post = Post.objects.create(**data.dict())
return 201, post
# Want caching? Use Django's cache_page
@cache_page(3600)
@djapify
def get_post(request, post_id: int) -> PostSchema:
return Post.objects.get(id=post_id)
🔥 Core Features
1. Simple by Default, Powerful When Needed
# Simple endpoint
@djapify
def get_tag(request, tag_slug: str) -> TagSchema:
return Tags.objects.get(slug=tag_slug)
# Need more power? Add async and pagination
@async_djapify
@paginate
async def get_tag_posts(request, tag_slug: str) -> List[PostSchema]:
tag = await Tags.objects.aget(slug=tag_slug)
return await tag.posts.aall()
2. Works with Django's Ecosystem
from django.views.decorators.cache import cache_page
from django.views.decorators.csrf import csrf_exempt
@cache_page(3600)
@csrf_exempt
@djapify(method="POST")
def create_user(request, data: UserSchema) -> {201: UserSchema}:
user = User.objects.create(**data.dict())
return 201, user
3. Simple Authentication
@djapify(auth=SessionAuth)
def get_profile(request) -> ProfileSchema:
return request.user.profile
# Need custom auth messages?
@djapify(auth=SessionAuth, msg={
"message": "Please log in first",
"redirect": "/login"
})
def protected_view(request) -> ProtectedSchema:
return {"data": "secret"}
4. Type-Safe Responses
@djapify
def get_post(request, post_id: int) -> {
200: PostSchema,
404: MessageSchema
}:
try:
return Post.objects.get(id=post_id)
except Post.DoesNotExist:
return 404, {
"message": "Post not found",
"type": "error"
}
🔄 Migration from DRF
| DRF Concept | Djapy Equivalent |
|---|---|
| ViewSets | Simple function views with @djapify |
| Serializers | Pydantic Schema models |
| Permissions | Built-in auth system |
| Filters | Native Python parameters |
| Pagination | @paginate decorator |
📚 Documentation
Visit djapy.io for comprehensive documentation.
🤝 Community & Support
- 📖 Documentation
- 💬 Community
- 🐛 Issue Tracker
- 📦 PyPI
Metadata
Release files for djapy 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djapy-0.2.1.tar.gz | 24.9 kB | Without provenance | Details for djapy-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| djapy-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for djapy-0.2.1-py3-none-any.whl |
Total release size: 55.5 kB
Release files / djapy-0.2.1.tar.gz
| Download URL | djapy-0.2.1.tar.gz |
|---|---|
| Size | 24.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d9c9c67b8a1ce86953bcc2ab3467982a8b074480c6ed1eb9ab0526318009e39
|
|
BLAKE2b-256 checksum How to use checksums |
6c4e27698075d65ba94fc1bd10d6613c52901521d7067aae1bc3e8e5ce479177
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.2
|
Release files / djapy-0.2.1-py3-none-any.whl
| Download URL | djapy-0.2.1-py3-none-any.whl |
|---|---|
| Size | 30.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
83903f86a5eacf9310d870d0d8bb32b6330a6fb478c6649038f49ced5f867d8d
|
|
BLAKE2b-256 checksum How to use checksums |
520e8f79a13c1b92637a1d4764e1cae81b07e9ab79b39fd88fe4bd660c969d0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.2
|
Security for djapy 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.