Skip to main content

tests

GitHub Actions Build Status Coverage Status Coverage Status

package

PyPI Package latest release PyPI Wheel Supported versions Supported implementations Commits since latest release

Utility code and patterns.

  • Free software: BSD 2-Clause License

Installation

pip install django-admin-utils

You can also install the in-development version with:

pip install https://github.com/ionelmc/django-admin-utils/archive/master.zip

Documentation

Terse admin.py

from django.contrib import admin
from admin_utils import register, inline

from .models import MyModel, OtherModel

@register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
    inlines = inline(OtherModel),

If you want custom admin sites:

customsite = admin.AdminSite()

@register(MyModel, site=customsite)
class MyModelAdmin(admin.ModelAdmin):
    inlines = inline(OherModel),

Mock admin (mount your views in admin using model wrappers)

Have you ever wanted a page in the admin that appears in the app list but you don’t have any models ? Now you can have that without patching up the admin Site or the templates. Just put this in your admin.py:

from django.urls import path
from admin_utils import make_admin_class

make_admin_class(
    app_label="test_app",
    model_name="Test1",
    urls=[
        path('', views.root, name='test_app_test1_changelist'),
        path('level1/', views.level1, name='level-1'),
        path('level1/level2/', views.level2, name='level-2'),
    ],
)

To use different admin site:

make_admin_class(
    site=customsite,
    app_label="test_app",
    model_name="Test1",
    urls=[
        path('', views.root, name='test_app_test1_changelist'),
        path('level1/', views.level1, name='level-1'),
        path('level1/level2/', views.level2, name='level-2'),
    ],
)

Alternatively you can mount a single view with a decorator:

from admin_utils import register_view

@register_view(
    site=customsite,
    app_label="test_app",
    model_name="Test1",
)
def root(request):
    ...

Admin mixins

admin_utils.mixins.FoldableListFilterAdminMixin

Adds nice filter toggling with cookie support. Largely based on django-foldable-list-filter but without the transition effect and no pictures.

Example:

from admin_utils.mixins import FoldableListFilterAdminMixin

class MyModelAdmin(FoldableListFilterAdminMixin, admin.ModelAdmin):
    pass

Looks like this:

Screenshort of FoldableListFilterAdminMixin

admin_utils.mixins.FullWidthAdminMixin

Make the changelist expand instead of having the width of the windows and having that nasty inner scrollbar. You never gonna notice that if your table is long !

Example:

from admin_utils.mixins import FoldableListFilterAdminMixin

class MyModelAdmin(FoldableListFilterAdminMixin, admin.ModelAdmin):
    pass

You probably didn’t even notice you had this problem:

Screenshort of FullWidthAdminMixin

Changelog

2.2.0 (2026-01-26)

  • Added Django 6.0 in test grid. Dropped Django 5.0 or older.

  • Added a missing ‘label’ attribute to fake models. Should allow you to use pghistory.admin as long as you have an adequate get_model in your AppConfig.

2.1.0 (2025-03-22)

  • Added support for Django 5.2.

  • Increased minimum versions to Django 4.2 and Python 3.9.

2.0.4 (2021-07-19)

  • Fixed mock admin regression and add test.

2.0.3 (2021-07-19)

  • Made the mock admin behave as without editable permissions (implemented the missing has_view_permission method).

2.0.2 (2021-07-18)

  • Exposed the fake hidden model as a fake_model attribute.

2.0.1 (2021-07-18)

  • Added missing import for admin_utils.register_view.

2.0.0 (2021-07-18)

  • Dropped support for Python 2.7 and Django 1.11.

  • Added the register_view decorator.

  • Update examples/readme.

  • Various bugfixes.

1.0.0 (2021-07-14)

  • Fixed a bunch of regressions with Django 3.2.

0.3.0 (2014-02-02)

  • Forgot to add any details.

Release files for django-admin-utils 2.2.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-utils 2.2.0
File Size Uploaded
django_admin_utils-2.2.0.tar.gz 67.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-utils 2.2.0
File Interpreter ABI Platform
django_admin_utils-2.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 76.6 kB

Release files / django_admin_utils-2.2.0.tar.gz

Download URL django_admin_utils-2.2.0.tar.gz
Size 67.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0bdfd995f877aa1086fb4bcbd9f3ea3e7fd464a598298eb500c50c4a0b461f46
BLAKE2b-256 checksum
How to use checksums
5771e106ff66335e12a38cd1044e97acc5ed2075a816a74689289024836433fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / django_admin_utils-2.2.0-py3-none-any.whl

Download URL django_admin_utils-2.2.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7f57b5c37574cc02ac4963012fdc8e0aae6acd8545ca1144827c8cc96bbc91b
BLAKE2b-256 checksum
How to use checksums
c851c24c58c7164bf0b5f6c4c3a82ae46d910bf8f53d88afa9b3c054d6358dca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.0

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

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