Skip to main content

Control the sort order of apps and models in the Django admin interface.

Project description

django-admin-app-model-sort

Control the sort order of apps and models in the Django admin index page.

This is an independent, unofficial third-party package. It is not affiliated with or endorsed by the Django Software Foundation.

Install

pip install django-admin-app-model-sort

Add to INSTALLED_APPS before django.contrib.admin:

INSTALLED_APPS = [
    "django_admin_app_model_sort",
    "django.contrib.admin",
    ...
]

Usage

Sort apps in the admin index

# myapp/apps.py
from django.apps import AppConfig

class MyAppConfig(AppConfig):
    name = "myapp"
    app_sort = 10  # lower appears first; omit to sort alphabetically after explicit ones

Sort models within an app

# myapp/admin.py
from django.contrib import admin
from .models import Invoice

@admin.register(Invoice)
class InvoiceAdmin(admin.ModelAdmin):
    model_sort = 1  # lower appears first within the app section

Apps and models without an explicit sort value fall back to alphabetical ordering and appear after all explicitly sorted ones.

How it works

Patches AdminSite.get_app_list() once at app startup (AppConfig.ready()). No Django source modifications. Zero rebase maintenance.

Running tests

pip install -e ".[dev]"
pytest

License

BSD-3-Clause.

Contribution

Issues and pull requests are welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_admin_app_model_sort-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_admin_app_model_sort-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file django_admin_app_model_sort-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django_admin_app_model_sort-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c5305556435bdaf9b2c36a401ffbb23568de2612f66fd82bdd8d5e517c9d0dbb
MD5 fbd3780672c9b08c4ec7172ab353cbb0
BLAKE2b-256 e686590340f74596dea8b3b22ea978345455cb57e1a55452a3b81e958a577efc

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_admin_app_model_sort-0.1.0.tar.gz:

Publisher: publish.yml on omidshojaee/django-admin-app-model-sort

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_admin_app_model_sort-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_app_model_sort-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b58851813f653c77e6ed1c28fcad05a2e3ba704b71f3ce2f37ccfb4e05dcc6df
MD5 60f12dc087a21426c07614b72690cf4f
BLAKE2b-256 853b105c3a8f64e8e8caaac59965aaccc6581d51db1e8a53055cd3c1c4912c93

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_admin_app_model_sort-0.1.0-py3-none-any.whl:

Publisher: publish.yml on omidshojaee/django-admin-app-model-sort

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page