Skip to main content
v1.2.1 What’s new →

Your Django models.
A REST API. No boilerplate.

Django Headless generates a REST API for your Django models. Decorate a model with @expose() and your Next.js, Astro or static site frontend can read it from predictable routes.

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)
GET/api/blog.articlelist
POST/api/blog.articlecreate
GET/api/blog.article/1retrieve
PUT/api/blog.article/1update
DELETE/api/blog.article/1delete

Everything included, nothing required

Routes per model

Decorate a model with @expose() and it gets list, detail, create, update and delete routes. You write no serializers, viewsets or URL patterns.

Fits your project

Works next to your existing apps, the Django admin and your Django REST Framework settings. Only the models you expose are in the API.

Singletons

Site settings and other one-off objects get a single GET and PUT route, created on the first write.

Filtering

Every lookup a field supports, from the query string: ?title__icontains=django. Exclude matches with ~.

Expandable relations

Include related exposed models inline with ?expand=, and serialize model properties as read-only fields.

Protected by default

Generated routes only answer staff users until you open them up. Secret key authentication, with a read-only key for the frontend, and read-only models are included.