This release is a pre-release and may not be stable for production use.
Django Headless
Django Headless generates a REST API for your Django models, so Django can serve as the backend of a headless CMS. Decorate a model with @expose() and it gets list, detail, create, update and delete routes, with no serializers, viewsets or URL patterns to write.
Read the documentation at djangoheadless.org.
Features
- Routes per model: one decorator generates the routes of a model.
- Singletons: site settings and other one-off objects as a single route.
- Filtering: every lookup a field supports, from the query string.
- Lookup routes: fetch an object by a unique field such as a slug, at
/api/blog.article/by_slug/<value>. - Pagination: a stable, paginated list envelope with ready-to-fetch links.
- OpenAPI schema: describe the routes, filters and fields for typed clients.
- TypeScript client: request the API from the frontend with types generated from the schema, with the
@django-headless/clientnpm package. - Predictable queries: relations load with a fixed number of queries, however long the list.
- Protected by default: generated routes only answer staff users until you open them up.
Quick start
-
Install the package:
pip install django-headless
-
Add
rest_framework,headlessandheadless.resttoINSTALLED_APPS:# mysite/settings.py INSTALLED_APPS = [ # ... "rest_framework", "headless", "headless.rest", ]
-
Include the API in your URL configuration:
# mysite/urls.py from django.urls import include, path urlpatterns = [ # ... path("api/", include("headless.rest.urls")), ]
-
Expose a model:
# blog/models.py from django.db import models from headless import expose @expose() class Article(models.Model): title = models.CharField(max_length=200) body = models.TextField() published = models.BooleanField(default=False) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title
Run python manage.py runserver; the article list is at /api/blog.article.
Generated routes answer 403 Forbidden to everyone but staff users, so an exposed model is never public by accident. To configure authentication or open the routes up, see Permissions.
Documentation
- Installation: requirements and setup
- Exposing models: the
@expose()options - Singletons: single-instance resources such as site settings
- Filtering: lookups, exclusions and type casting
- Pagination: the list envelope
- Authentication: secret key and DRF authentication
- Serializers: expanding relations and model properties
- Permissions: defaults and overrides for generated routes
- OpenAPI schema: the schema of the generated routes
- TypeScript client: the
@django-headless/clientnpm package - Settings reference: every
HEADLESSsetting - System checks: the checks for risky or broken settings
Contributing
To contribute a change:
- Fork the repository.
- Create a branch:
git checkout -b fix-boolean-casting. - Make the change and add tests for it.
- Run the test suite:
poetry run python scripts/test_wrapper.py test. - Commit and push the branch.
- Open a pull request.
Set up a development environment with Poetry:
git clone https://github.com/dwarsbit/django-headless.git
cd django-headless
poetry install
poetry run python scripts/test_wrapper.py test
The TypeScript client lives in client/, with its own tests:
cd client
npm ci
npm test
npm run typecheck
poetry run npm run e2e:next # against a Django project and a Next.js app
Writing for the README or the documentation follows STYLE.md.
Support
- Bug reports: GitHub Issues
- Questions: GitHub Discussions
- Email: leon@dwarsbit.nl
License
Django Headless is licensed under the MIT License; see LICENSE.
Links
Metadata
Release files for django-headless 1.1.0rc1
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 |
|---|---|---|---|---|
| django_headless-1.1.0rc1.tar.gz | 38.2 kB | With provenance | Details for django_headless-1.1.0rc1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_headless-1.1.0rc1-py3-none-any.whl | Python 3 | none | any | Details for django_headless-1.1.0rc1-py3-none-any.whl |
Total release size: 85.3 kB
Release files / django_headless-1.1.0rc1.tar.gz
| Download URL | django_headless-1.1.0rc1.tar.gz |
|---|---|
| Size | 38.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3e7aa299de4df11bb4df1a5333f975b302f1232d9c90b3cc8687ad6d3614216
|
|
BLAKE2b-256 checksum How to use checksums |
6a0a907953f4d3f1c9494597b8c95dafd58e12289514a2f2fedd1617cee41e2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logRelease files / django_headless-1.1.0rc1-py3-none-any.whl
| Download URL | django_headless-1.1.0rc1-py3-none-any.whl |
|---|---|
| Size | 47.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfd7f3707ce00eeac1ac51ac93be6f053fae676de0fcb9ec44b688885f9bc2ba
|
|
BLAKE2b-256 checksum How to use checksums |
26434cad0f3116825c82650fc3e406698f9965714cf8c6d7062d77ba860cd3b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logSecurity for django-headless 1.1.0rc1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for django_headless-1.1.0rc1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logA 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.