Blog Entry 9 years ago

Django application automatically loads all models into admin

Sometimes I feel a little bored when having to add lot of models into admin section, especially during the development. Therefore, I made django-quickadmin with hope it will ease that registering process.

At first, I have part of the script inside an existing application for loading all models from other applications into admin dynamically. Then, I think it would be convenient for next work if it stays as separate Django application.

So this is its repo in Github: https://github.com/zniper/django-quickadmin

The application is now compatible with Django >= 1.5 (Python >= 2.6) and core functionality is quite simple, with just a few functions:

  1. Find all the found models within the current Django project
  2. Filter and register only the models not in exclusion
  3. Rebuild the admin URLs

To install the application:

1. Install the Python package:

pip install django-quickadmin

2. Put `quickadmin` into INSTALLED_APPS tuple/list in settings module.

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    ...
    'quickadmin',
    ...
)

3. Restart the project 


Currently it has only 2 configurable options:

QADMIN_EXCLUDES - List of applications or models which will be bypassed/hidden in admin area. In the case below, all undeclared models of my_first_app and the model my_second_app.JustOneModel will be excluded.

QADMIN_EXCLUDES = [
    'my_first_app',
    'my_second_app.JustOneModel',
]

QADMIN_EXCLUDE_STOCK - Option for excluding default/stock applications of Django or not (default = True).

QADMIN_EXCLUDE_STOCK = False    # models of applications like: south, contenttypes,.. will be shown

 

Finally, if you have time and courage, please try the application and let me know if there are further ideas or any issues.

Recent Reads