Skip to main content

Django Admin Generator

Scaffold a complete, sensible Django admin for your models in one command.

CI on master Coverage on master PyPI version Python versions Monthly downloads Documentation License

django-admin-generator is a management command that introspects your models and writes a ready-to-use admin.py: list_display, list_filter, search_fields, raw_id_fields, date_hierarchy, prepopulated_fields and autocomplete, so you don't have to hand-write any of it.

Auto-generated changelist

The list view above, filter sidebar and date drill-down included, came straight from the models with no hand-written admin code.

Quick start

pip install django-admin-generator

Add django_admin_generator to your INSTALLED_APPS, then generate an admin and write it to the app's admin.py:

./manage.py admin_generator <app> --write

Reload the Django admin. Your models are fully wired up.

What gets generated

For every model, the generator inspects the fields and picks sensible options:

Model trait Generated option
All local fields list_display
DateField, BooleanField, low-cardinality fields & foreign keys list_filter
Foreign key to a large table (≥ raw_id_threshold, default 100) raw_id_fields
ManyToManyField autocomplete_fields (or raw_id_fields)
name / slug fields search_fields
slug field prepopulated_fields (from name/title)
created_at / updated_at / joined_at date_hierarchy
TextField / JSONField / BinaryField / FileField shown, but kept out of list_filter (DISTINCT is unsafe on some databases)

The result is plain, readable code you can keep or tweak:

class PostAdmin(ModelAdminBase):
    list_display = (
        'id', 'title', 'slug', 'body', 'created_at',
        'published_at', 'is_published', 'author', 'category',
    )
    list_filter = ('created_at', 'published_at', 'is_published', 'author', 'category')
    autocomplete_fields = ('tags',)
    search_fields = ('slug',)
    prepopulated_fields = {'slug': ['title']}
    date_hierarchy = 'created_at'

That produces a fully wired add/change form: prepopulated slugs, autocomplete for relations, and the right widgets everywhere:

Auto-generated add form

Usage

By default the output is printed to stdout so you can review it before writing:

./manage.py admin_generator <app>                 # print to stdout
./manage.py admin_generator <app> '^user'         # only models matching a regex
./manage.py admin_generator <app> --write         # write <app>/admin.py
./manage.py admin_generator <app> -o admin.py -f  # custom output file, overwrite
./manage.py admin_generator all                   # every local (non site-packages) app

Handy options:

Option Effect
-w, --write write to the app's admin.py (otherwise stdout)
-o/--output, -f/--force, -a/--append output-file handling
-l/--list-filter-threshold, -r/--raw-id-threshold, --date-hierarchy-threshold tune the heuristics
-s/--search-field, -d/--date-hierarchy, -p/--prepopulated-fields add extra field names
-n/--no-query-db don't query the database for row counts
--enable-reversion, --disable-json-widget, --disable-auto-complete integrations & toggles

Run ./manage.py admin_generator --help for the full list.

Tip: pairs perfectly with Django's inspectdb for legacy databases: generate the models, then generate the admin.

Live demo

Spin up a self-documenting blog demo whose admin.py is fully auto-generated:

tox -e demo        # or: uv run --extra demo python test_project/manage.py demo

It migrates, seeds realistic data, and opens the admin (login admin / admin). The index page explains exactly what was generated and why:

Self-documenting demo index

See test_project/README.md for a guided tour.

Compatibility

  • Python 3.10 to 3.14
  • Django 4.2, 5.0, 5.1, 5.2, 6.0, 6.1

Development

This project uses uv and tox:

uv sync --extra dev      # create the environment
uv run pytest            # run the tests (100% coverage)
uv run ruff check .      # lint
uv run tox               # full matrix: tests, lint, types, docs

Support

django-admin-generator is maintained by Rick van Hattem in his own time.

If it saved you an afternoon, a tip covers an hour of issue triage: Ko-fi or GitHub Sponsors.

If your company funds its dependencies, this package is on thanks.dev.

ko-fi

License

BSD-3-Clause, see LICENSE.

Metadata

Release files for django-admin-generator 3.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-admin-generator 3.1.0
File Size Uploaded Provenance
django_admin_generator-3.1.0.tar.gz 15.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-generator 3.1.0
File Interpreter ABI Platform
django_admin_generator-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.0 kB

Release files / django_admin_generator-3.1.0.tar.gz

Download URL django_admin_generator-3.1.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
29e16dada15af3c7dea13abc73d5dd391942c5ddb205693b08efcca5f9d03bed
BLAKE2b-256 checksum
How to use checksums
79cc07b60232b840107e549217eea851417970447a23036a634cdd5b17c34784
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 Oct 28, 2026.

Transparency log

Release files / django_admin_generator-3.1.0-py3-none-any.whl

Download URL django_admin_generator-3.1.0-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9fd518423b5ea7fbab755905dee6f7cd135838bf309fa5b5f90e882996fa2574
BLAKE2b-256 checksum
How to use checksums
d07fe126613280088420ed01a41ae4e34ac7b585a895ba6db931ffe5bc907d28
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 Oct 28, 2026.

Transparency log

Security for django-admin-generator 3.1.0

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_admin_generator-3.1.0.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 28, 2026.

Transparency log

A 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.

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