Skip to content

omidshojaee/django-admin-sortkey

Repository files navigation

django-admin-sortkey

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

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-sortkey

Add to INSTALLED_APPS before django.contrib.admin:

INSTALLED_APPS = [
    "django_admin_sortkey",
    "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, matching Django's own license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages