Installation
Requirements
- Python 3.10+
- Django 4.2+
- Django REST Framework 3.14+
pyproject.toml is the source of truth for supported versions.
Install
pip install turbodrf
This also installs Django REST Framework, django-filter and drf-yasg. Optional extras (quote them, or zsh expands the brackets):
pip install "turbodrf[fast]" # msgspec: faster JSON rendering
pip install "turbodrf[allauth]" # django-allauth group-to-role mapping (experimental)
From GitHub:
pip install git+https://github.com/AlexanderCollins/TurboDRF.git
To work on TurboDRF itself, see CONTRIBUTING.md.
Set up a project
The Quick start builds a working project step by step. In short:
- Add
'rest_framework','drf_yasg'and'turbodrf'toINSTALLED_APPS.drf_yasgserves the Swagger / ReDoc pages; without them, leave it out and setTURBODRF_ENABLE_DOCS = False(with neither, Django’s system check warnsturbodrf.W001). - Define
TURBODRF_ROLESand give users roles throughuser.roles(see Assigning roles to users). - Add
path('api/', include('turbodrf.urls'))to your URLconf. - Add
TurboDRFMixinand aturbodrf()classmethod to each model the API should expose (Configuration), and decide how its rows are scoped (Tenancy).
Run python manage.py check in CI and before each deploy: it imports the
URLconf, which runs TurboDRF’s startup checks (see
Management commands).
Troubleshooting
Every request is a 403. The user has no role, or no role grants the
action. Check user.roles and TURBODRF_ROLES. Anonymous callers get a 403
unless the model sets public_access: True, and then only for reads.
A nested field (author__name) is missing. The caller needs read on the
related model too (myapp.author.read).
A model has no endpoint. Check that it inherits TurboDRFMixin, defines
turbodrf(), and doesn’t set 'enabled': False. The endpoint is the
lowercase model name plus s (/api/books/) unless 'endpoint' is set.
Users see each other’s rows. Roles don’t scope rows. Declare
owner_field, tenant_field or visibility (see Tenancy).
Uninstall
pip uninstall turbodrf
Then remove 'turbodrf' from INSTALLED_APPS and the TurboDRF imports from
your code.