A Django app that registers all unregistered models to the admin automatically.
Project description
Django admin autoregister
This is a simple app that automatically registers all the models that have not yet been registered to the Django admin.
It also does the following:
- Adds all fields except
TextFieldtolist_display. - Optimizes the database queries by selecting related fields.
- Adds fields that have
choicesset tolist_filter. - If a model only has one
DateFieldorDateTimeFieldit adds that field to thedate_hierarchy - Sets
raw_id_fieldfor related fields andautocomplete_fieldsfor related fields that havesearch_fieldsset. - Only registers models that you haven't yet registered.
- Ignores models that you wish to exclude from the admin.
Installation
- Install django-admin-autoregister
pip install django-admin-autoregister
or
pipenv install django-admin-autoregister
- Add
admin_autoregisterto the bottom INSTALLED_APPS setting like this:
INSTALLED_APPS = [
# ...
'admin_autoregister',
]
Be extra careful to include it as the last app in the list, otherwise your own admin registrations will raise exceptions.
All your models should now be registered in the admin.
-
You can use the following settings to tweak the admin auto registration:
ADMIN_AUTOREGISTER_EXCLUDEis a list of models to exclude in the admin.- Defaults to
['contenttypes.ContentType', 'auth.Permission', 'session.Session', 'admin.LogEntry',]'
- Defaults to
ADMIN_AUTOREGISTER_EXCLUDE_INLINESis a boolean that determines whether or not to exclude models that are already registered as inlines of other models.- Defaults to
True
- Defaults to
ADMIN_AUTOREGISTER_UNREGISTER_LISTis a list of models to unregister from admin. This is usefull when you want to unregister models from other apps such as Celery, Oauth which are registered by default.- Defaults to
[]
- Defaults to
Mixins
Each of the autoregister features can be used in your registered models by adding them as mixins.
The available mixins are:
admin_autoregister.mixins.ListDisplayAdminMixin- Populates thelist_displayautomatically.admin_autoregister.mixins.ListFilterAdminMixin- Populates thelist_filterattribute automatically.admin_autoregister.mixins.AutocompleteFieldsAdminMixin- Populates theraw_id_fieldsandautocomplete_fieldsattributes automatically.admin_autoregister.mixins.SelectRelatedFieldsAdminMixin- Automatically selects all related fields with the queryset.admin_autoregister.mixins.DateHierarchyAdminMixin- Automatically sets thedate_hierarchyif there's only oneDateTimeFieldorDateField
Contributing
Contributions are very welcome - submit a PR!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-admin-autoregister-1.1.0.tar.gz.
File metadata
- Download URL: django-admin-autoregister-1.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65bd465b88b18e11a25538a7ebb27c627b1b477ec9858cf6e93bb829b1dbd505
|
|
| MD5 |
ad0a5be1c268d801436c5ce4173a10a6
|
|
| BLAKE2b-256 |
02ce562c4a2abbdfad8446b5d45fcb4c2fc0e1b904393a8433fda373ad4213e6
|
File details
Details for the file django_admin_autoregister-1.1.0-py3-none-any.whl.
File metadata
- Download URL: django_admin_autoregister-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f26062f95b2d368d9f0bda8d3ef085431917f17ae31811db4da72e9836d89dd3
|
|
| MD5 |
c13b1b707ab2a1614d5e51de9f1d2dee
|
|
| BLAKE2b-256 |
3b1edd5b9863e0219f932d57ffe53172c34a250daf693303c4b209b563b7359f
|