Skip to main content

django-api-starter

Generate a production-ready Django REST API project in one command. You get a custom email-based user, JWT authentication, profile and password APIs, and optional email OTP / two-factor login. The layout is flat and easy to read.

pip install django-api-starter
django-starter new myproject

What you get

myproject/
├── apps/
│   └── accounts/          # User model, serializers, views, urls, admin, migrations
├── conf/
│   ├── settings/          # base.py, development.py, production.py, test.py
│   ├── asgi.py
│   ├── urls.py
│   └── wsgi.py
├── core/                  # JWT helpers, error format, pagination, permissions, middleware
│   └── management/commands/wait_for_db.py
├── requirements/          # base.txt, development.txt, production.txt
├── templates/emails/      # password reset (and OTP) emails
├── tests/                 # pytest suite for every endpoint
├── .env / .env.example
├── Dockerfile / docker-compose.yml   (optional)
├── manage.py
└── pytest.ini

User model: email login, name, phone, profile picture, role (admin / user), active flag and timestamps. With 2FA it also has is_email_verified and two_factor_enabled.

Endpoints (under /api/v1/):

auth/register/, auth/login/, auth/logout/, auth/token/refresh/ Registration and JWT login. Refresh tokens rotate and are blacklisted after use
auth/me/ (GET / PATCH) Read or update your profile, including the picture upload
auth/password/change/, auth/password/reset/, auth/password/reset/confirm/ Change a password, or reset a forgotten one by email
auth/otp/verify/, auth/otp/resend/ Email OTP (only with --2fa)
users/, users/<id>/ Admin-only user list and management

With --2fa:

  • Signup emails a code to verify the address.
  • Login asks for a code when the email isn't verified yet, or when the user has turned on two_factor_enabled.
  • No JWT is issued until the code is verified.
  • Codes are hashed, single-use, expire, lock after too many wrong tries, and have a resend cooldown.

Also included: a consistent error format, rate limiting on the auth endpoints, CORS, .env config, a request-ID middleware, a health check, Swagger docs, PostgreSQL or SQLite, and Docker.

Usage

django-starter new myproject                  # interactive: asks about each option
django-starter new myproject -y               # accept the defaults
django-starter new myproject ./path/to/dir --database sqlite --2fa --no-docker -y
Option Default
--database {postgres,sqlite} postgres Sets up requirements, .env and docker-compose
--2fa / --no-2fa off Email OTP verification and two-factor login
--docker / --no-docker on Dockerfile, docker-compose.yml, .dockerignore
--api-docs / --no-api-docs on OpenAPI schema at /api/schema/, Swagger UI at /api/docs/
-y, --yes Don't prompt

Generated projects need Python 3.12+ and Django 6.1+.

Developing this package

pip install -e ".[dev]"
pytest

src/django_api_starter/template/ holds the project template:

  • *.j2 files are rendered with Jinja2. Python files are always .j2, so they are never byte-compiled at install time.
  • Other files are copied as they are. This keeps Django's own {{ }} syntax in the email templates intact.
  • dot-name becomes .name.
  • OPTIONAL_FILES in generator.py maps files to the feature flag that turns them on.

If the generated project's dependencies are installed, pytest also generates projects and runs their migration check, OpenAPI validation and test suites. Install them from a generated project:

django-starter new deps ../deps --database sqlite -y
pip install -r ../deps/requirements/development.txt

If you change a model, regenerate apps/accounts/migrations/0001_initial.py.j2: generate a project, delete its migration, run makemigrations, and copy the result back with the {% if two_factor %} blocks.

Releasing

The version lives only in src/django_api_starter/__init__.py (__version__).

  1. Bump __version__, commit and push to main, and wait for CI to pass.
  2. Create a GitHub release with the tag v<version> (for example v0.1.1).
  3. The Publish workflow checks that the tag matches __version__, builds, and uploads to PyPI with trusted publishing. No token is needed.

Run the Publish workflow manually (Actions → Publish → Run workflow) to upload to TestPyPI instead. TestPyPI rejects a version it already has, so bump __version__ before each rehearsal upload.

Release files for django-api-starter 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-api-starter 0.1.0
File Size Uploaded
django_api_starter-0.1.0.tar.gz 35.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-api-starter 0.1.0
File Interpreter ABI Platform
django_api_starter-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 82.6 kB

Release files / django_api_starter-0.1.0.tar.gz

Download URL django_api_starter-0.1.0.tar.gz
Size 35.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d496f25b7a922ae9c4daed5f8b5f6423862f51c8add648430f56c5c3f53f471c
BLAKE2b-256 checksum
How to use checksums
a648b7e94334d65ca817896db7717b7f13e51774ac7ab0fa6c16baf41a2c577c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 24, 2026.

Transparency log

Release files / django_api_starter-0.1.0-py3-none-any.whl

Download URL django_api_starter-0.1.0-py3-none-any.whl
Size 47.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8125a03efbf1a448412b8c96328e793fbba26dd6c41348db680e7bfca4f7f34f
BLAKE2b-256 checksum
How to use checksums
f6c876a00dc5f1b9b1ce9a5c697fa7ad6653ccabb8c89943561f275d6ae10632
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page