Welcome to Django Admin Generator’s documentation!

Contents:

Readme

Introduction

Build status:

django-admin-generator test status

Coverage:

Coverage Status

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

Install

To install:

  1. Run pip install django-admin-generator or execute python setup.py install in the source directory
  2. Add django_admin_generator to your INSTALLED_APPS

If you want to run the tests, run py.test (requires pytest)

Usage

To generate an admin for a given app:

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

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

./manage.py admin_generator APP_NAME ‘^user’ >> APP_NAME/admin.py

django_admin_generator package

Subpackages

django_admin_generator.management package

Subpackages
django_admin_generator.management.commands package
Submodules
django_admin_generator.management.commands.admin_generator module
class django_admin_generator.management.commands.admin_generator.AdminApp(app, model_res, **options)[source]

Bases: object

class django_admin_generator.management.commands.admin_generator.AdminModel(model, raw_id_threshold=100, date_hierarchy_threshold=250, list_filter_threshold=25, search_field_names=('name', 'slug'), date_hierarchy_names=('joined_at', 'updated_at', 'created_at'), prepopulated_field_names=('slug=name', ), no_query_db=False, **options)[source]

Bases: object

PRINTABLE_PROPERTIES = ('list_display', 'list_filter', 'raw_id_fields', 'search_fields', 'prepopulated_fields', 'date_hierarchy')
name
class django_admin_generator.management.commands.admin_generator.Command[source]

Bases: django_utils.management.commands.base_command.CustomBaseCommand

add_arguments(parser)[source]

Entry point for subclassed commands to add custom arguments.

can_import_settings = True
handle(app=None, *args, **kwargs)[source]

The actual logic of the command. Subclasses must implement this method.

handle_app(app, model_res, **options)[source]
help = 'Generate a `admin.py` file for the given app (models)'
requires_system_checks = ('__all__',)
warning(message)[source]

Log a message with severity ‘WARNING’ on the root logger. If the logger has no handlers, call basicConfig() to add a console handler with a pre-defined format.

django_admin_generator.management.commands.admin_generator.get_apps()[source]
django_admin_generator.management.commands.admin_generator.get_models(app)[source]
Module contents
Module contents

Module contents

Indices and tables