Skip to main content

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 TextField to list_display.
  • Optimizes the database queries by selecting related fields.
  • Adds fields that have choices set to list_filter.
  • If a model only has one DateField or DateTimeField it adds that field to the date_hierarchy
  • Sets raw_id_field for related fields and autocomplete_fields for related fields that have search_fields set.
  • 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_autoregister to 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_EXCLUDE is a list of models to exclude in the admin.
      • Defaults to ['contenttypes.ContentType', 'auth.Permission', 'session.Session', 'admin.LogEntry',]'
    • ADMIN_AUTOREGISTER_EXCLUDE_INLINES is a boolean that determines whether or not to exclude models that are already registered as inlines of other models.
      • Defaults to True
    • ADMIN_AUTOREGISTER_UNREGISTER_LIST is 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 []

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 the list_display automatically.
  • admin_autoregister.mixins.ListFilterAdminMixin - Populates the list_filter attribute automatically.
  • admin_autoregister.mixins.AutocompleteFieldsAdminMixin - Populates the raw_id_fields and autocomplete_fields attributes automatically.
  • admin_autoregister.mixins.SelectRelatedFieldsAdminMixin - Automatically selects all related fields with the queryset.
  • admin_autoregister.mixins.DateHierarchyAdminMixin - Automatically sets the date_hierarchy if there's only one DateTimeField or DateField

Contributing

Contributions are very welcome - submit a PR!

Metadata

Release files for django-admin-autoregister 1.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-autoregister 1.1.0
File Size Uploaded Provenance Actions
django-admin-autoregister-1.1.0.tar.gz 4.3 kB Without provenance Details for django-admin-autoregister-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-autoregister 1.1.0
File Interpreter ABI Platform Actions
django_admin_autoregister-1.1.0-py3-none-any.whl Python 3 none any Details for django_admin_autoregister-1.1.0-py3-none-any.whl

Total release size: 9.8 kB

Release files / django-admin-autoregister-1.1.0.tar.gz

Download URL django-admin-autoregister-1.1.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
65bd465b88b18e11a25538a7ebb27c627b1b477ec9858cf6e93bb829b1dbd505
BLAKE2b-256 checksum
How to use checksums
02ce562c4a2abbdfad8446b5d45fcb4c2fc0e1b904393a8433fda373ad4213e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / django_admin_autoregister-1.1.0-py3-none-any.whl

Download URL django_admin_autoregister-1.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f26062f95b2d368d9f0bda8d3ef085431917f17ae31811db4da72e9836d89dd3
BLAKE2b-256 checksum
How to use checksums
3b1edd5b9863e0219f932d57ffe53172c34a250daf693303c4b209b563b7359f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for django-admin-autoregister 1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

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