{% extends "main.html" %} {#- Home for rebuilt 1.x/2.x docs. docs-legacy/migrate.py fills the @@...@@ slots per version. -#} {% macro first_url(item) -%} {%- if item.url -%}{{ item.url | url }}{%- elif item.children -%}{{ first_url(item.children | first) }}{%- endif -%} {%- endmacro %} {% block container %} {% set sections = nav.items | selectattr("children") | list %}
v{{ config.extra.nac_version }} You're reading an older version. See the latest

Your Django models,
served as REST APIs.

Say which fields each operation reads and writes. django-ninja-aio-crud builds the async Django Ninja endpoints, validation and OpenAPI schema for you.

Get started {% for section in sections if section.title | lower == "tutorial" %} Take the tutorial {% endfor %}
  • Version {{ config.extra.nac_version }}
  • Fully async
  • MIT license
from django.db import models
from ninja_aio.models import ModelSerializer


class Article(ModelSerializer):
    title = models.CharField(max_length=200)
    body = models.TextField()

    class ReadSerializer:
        fields = ["id", "title", "body"]

    class CreateSerializer:
        fields = ["title", "body"]

    class UpdateSerializer:
        optionals = [("title", str), ("body", str)]

Generated endpoints

  • GET/api/articlesList, paginated
  • POST/api/articles/Create
  • GET/api/articles/{id}Retrieve
  • PATCH/api/articles/{id}/Partial update
  • DELETE/api/articles/{id}/Delete
200 OK
{
  "items": [{ "id": 1, "title": "Hello", "body": "..." }],
  "count": 1
}

How it works

Three steps from model to API

  1. 1

    Describe the fields

    Inner serializer classes list what each operation reads and writes.

  2. 2

    Register a viewset

    @@REGISTER_TEXT@@

  3. 3

    Ship the endpoints

    Five validated async routes and an OpenAPI schema.

Features

What's in {{ config.extra.nac_version }}

Start with a few lines. Add the rest when you need it.

@@CARDS@@
@@PERF@@

Where to go next

Pick your path

@@PATHS@@

Build your first endpoint now

Install the package and follow the docs for {{ config.extra.nac_version }}.

{% endblock %}