Skip to main content

Dead simple Django REST API generator with role-based permissions

Project description

TurboDRF

PyPI Version Tests License

Dead simple Django REST Framework API generator with role-based permissions.

Turn your Django models into fully-featured REST APIs with a mixin and a method. Zero boilerplate.

Install

pip install turbodrf

Quick Start

1. Add to settings:

INSTALLED_APPS = [
    'rest_framework',
    'turbodrf',
]

2. Add the mixin to your model:

from django.db import models
from turbodrf.mixins import TurboDRFMixin

class Book(models.Model, TurboDRFMixin):
    title = models.CharField(max_length=200)
    author = models.ForeignKey(Author, on_delete=models.CASCADE)
    price = models.DecimalField(max_digits=10, decimal_places=2)

    searchable_fields = ['title']

    @classmethod
    def turbodrf(cls):
        return {
            'fields': {
                'list': ['title', 'author__name', 'price'],
                'detail': ['title', 'author__name', 'author__email', 'price']
            }
        }

3. Add the router:

from turbodrf.router import TurboDRFRouter

router = TurboDRFRouter()

urlpatterns = [
    path('api/', include(router.urls)),
]

Done. You now have a full REST API with search, filtering, pagination, and field selection:

GET    /api/books/                          # List
GET    /api/books/1/                        # Detail
POST   /api/books/                          # Create
PUT    /api/books/1/                        # Update
DELETE /api/books/1/                        # Delete
GET    /api/books/?search=django            # Search
GET    /api/books/?price__lt=20             # Filter
GET    /api/books/?fields=title,price       # Select fields

Documentation

  • Configuration -- all turbodrf() options, field selection, nested fields
  • Permissions -- role-based, field-level, and Django default permissions
  • Performance -- compiled read path, fast JSON rendering, benchmarking
  • Filtering & Search -- filtering, search, ordering, OR queries
  • Integrations -- allauth, Keycloak, drf-api-tracking
  • Security -- sensitive fields, secure defaults, error responses
  • Management Commands -- turbodrf_check, turbodrf_benchmark, turbodrf_explain

License

MIT License. See LICENSE for details.

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

turbodrf-0.3.0.tar.gz (118.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

turbodrf-0.3.0-py3-none-any.whl (69.7 kB view details)

Uploaded Python 3

File details

Details for the file turbodrf-0.3.0.tar.gz.

File metadata

  • Download URL: turbodrf-0.3.0.tar.gz
  • Upload date:
  • Size: 118.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for turbodrf-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5006a0fcef14844fe24268a2cbccecd87779351ff1785d34a796060139518c4d
MD5 f14c388a2404ead515ea17d1f51040bc
BLAKE2b-256 b1af633d3e42db35aced2537621795262438bbe2d0f25b47960de0bf766603a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for turbodrf-0.3.0.tar.gz:

Publisher: publish.yml on AlexanderCollins/TurboDRF

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file turbodrf-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: turbodrf-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 69.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for turbodrf-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8000bdbd0fe8a45da070d5106863175c3106ccb7953ac64c235249bc979972c7
MD5 a80dd806a43b22a9206a4ef8717812a4
BLAKE2b-256 ee1c7420d0c6733f6dd90c7b3f65b2c546b5cb1a33ceb36c796dc4f707c94af1

See more details on using hashes here.

Provenance

The following attestation bundles were made for turbodrf-0.3.0-py3-none-any.whl:

Publisher: publish.yml on AlexanderCollins/TurboDRF

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page