Skip to content

Getting started with django-admin-contexts

Python Compatibility Django Compatibility PyPi Version CI badge codecov License

Display only a set of apps and models in the Django Admin homepage, based on the chosen context. This is useful when you have a lot of apps and models and you want to focus on a specific set of them.

Demo: selecting a context to display only a subset of models

Installation

Via pip command:

pip install django-admin-contexts

...or you can clone the repo and install it using pip too:

git clone git://github.com/matagus/django-admin-contexts.git
cd django-admin-contexts
pip install -e .

Quick Start

Add django_admin_contexts to your INSTALLED_APPS in settings.py before django.contrib.admin:

INSTALLED_APPS = (
    # ...
    "django_admin_contexts",
    # ...
    "django.contrib.admin",
    # ...
)

Then run the migrations:

python manage.py migrate

Usage

Browse to the Django Admin and create some contexts in the "Django Admin Contexts" section, associating them with one or more models.

Then, you can see the contexts in the Django Admin homepage.

Running Tests

Prerequisites: Install Hatch if not already installed: pip install hatch

List available test environments:

hatch env show test

Run all tests (all Python + Django combinations):

hatch run test:test

Run tests for specific Python/Django version:

hatch run test.py3.14-5.2:test  # Python 3.14 + Django 5.2
hatch run test.py3.12-5.1:test  # Python 3.12 + Django 5.1

Run specific test file:

hatch run test.py3.14-5.2:test tests.test_models

Coverage:

hatch run test:cov  # Run tests with coverage report

Troubleshooting: If you encounter environment issues, clean and rebuild: hatch env prune