Metadata-Version: 2.4
Name: django-admin-generator
Version: 3.0.0
Summary: Django Admin Generator is a management command to automatically generate a Django `admin.py` file for given apps/models.
Keywords: django,admin,generator,scaffold
Author: Rick van Hattem
Author-email: Rick van Hattem <Wolph@Wol.ph>
License-Expression: BSD-3-Clause
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Framework :: Django :: 5.2
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Dist: django-utils2>=2.12.1
Requires-Dist: python-utils>=3.5.2
Requires-Dist: django>=4.2 ; extra == 'demo'
Requires-Dist: django-admin-generator[tests] ; extra == 'dev'
Requires-Dist: ruff>=0.15.0 ; extra == 'dev'
Requires-Dist: mypy>=1.10 ; extra == 'dev'
Requires-Dist: django-stubs[compatible-mypy]>=5.0 ; extra == 'dev'
Requires-Dist: pyright>=1.1 ; extra == 'dev'
Requires-Dist: pyrefly>=0.1 ; extra == 'dev'
Requires-Dist: sphinx>=7 ; extra == 'docs'
Requires-Dist: django>=4.2 ; extra == 'docs'
Requires-Dist: pytest>=8 ; extra == 'tests'
Requires-Dist: pytest-cov>=5 ; extra == 'tests'
Requires-Dist: pytest-django>=4.8 ; extra == 'tests'
Requires-Dist: coverage>=7 ; extra == 'tests'
Requires-Dist: django>=4.2 ; extra == 'tests'
Requires-Dist: tox>=4.0 ; extra == 'tox'
Requires-Dist: tox-uv>=1.0 ; extra == 'tox'
Requires-Dist: tox-gh-actions>=3.0 ; extra == 'tox'
Requires-Python: >=3.10
Project-URL: Homepage, https://github.com/WoLpH/django-admin-generator/
Project-URL: Documentation, https://django-admin-generator.readthedocs.io/
Project-URL: Source, https://github.com/WoLpH/django-admin-generator/
Project-URL: Bug Reports, https://github.com/WoLpH/django-admin-generator/issues
Provides-Extra: demo
Provides-Extra: dev
Provides-Extra: docs
Provides-Extra: tests
Provides-Extra: tox
Description-Content-Type: text/markdown

# Django Admin Generator

[![CI](https://github.com/WoLpH/django-admin-generator/actions/workflows/ci.yml/badge.svg)](https://github.com/WoLpH/django-admin-generator/actions/workflows/ci.yml)
[![PyPI version](https://img.shields.io/pypi/v/django-admin-generator.svg)](https://pypi.org/project/django-admin-generator/)
[![Python versions](https://img.shields.io/pypi/pyversions/django-admin-generator.svg)](https://pypi.org/project/django-admin-generator/)
[![Documentation Status](https://readthedocs.org/projects/django-admin-generator/badge/?version=latest)](https://django-admin-generator.readthedocs.io/en/latest/)

The Django Admin Generator is a project which can automatically generate
(scaffold) a Django Admin for you. By doing this it will introspect your
models and automatically generate an Admin with properties like:

- `list_display` for all local fields
- `list_filter` for foreign keys with few items
- `raw_id_fields` for foreign keys with a lot of items
- `search_fields` for `name` and `slug` fields
- `prepopulated_fields` for `slug` fields
- `date_hierarchy` for `created_at`, `updated_at` or `joined_at` fields

## Links

- **Documentation**: <https://django-admin-generator.readthedocs.io/en/latest/>
- **Source**: <https://github.com/WoLpH/django-admin-generator>
- **Bug reports**: <https://github.com/WoLpH/django-admin-generator/issues>
- **Package homepage**: <https://pypi.org/project/django-admin-generator/>
- **My blog**: <https://w.wol.ph/>

## Install

1. Install the package:

   ```sh
   pip install django-admin-generator
   ```

2. Add `django_admin_generator` to your `INSTALLED_APPS`.

## Usage

To generate an admin for a given app:

```sh
./manage.py admin_generator APP_NAME >> APP_NAME/admin.py
```

To generate an admin for a given app with all models starting with `user`:

```sh
./manage.py admin_generator APP_NAME '^user' >> APP_NAME/admin.py
```

To write the generated admin directly to each app's `admin.py`:

```sh
./manage.py admin_generator APP_NAME --write
```

Use `all` as the app name to generate admins for every local (i.e. not in
`site-packages`) app:

```sh
./manage.py admin_generator all
```

## Live demo

A self-documenting blog demo whose `admin.py` is fully auto-generated:

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

Then open <http://127.0.0.1:8000/admin/> and log in with `admin` / `admin`. The
admin index explains what was generated and why. See
[`test_project/README.md`](https://github.com/WoLpH/django-admin-generator/blob/develop/test_project/README.md)
for a guided tour.

## Development

This project uses [uv](https://docs.astral.sh/uv/) and
[tox](https://tox.wiki/):

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