Django Admin Plus

0.6 · active · verified Sun Apr 12

AdminPlus is a Django admin panel extension that allows you to add custom views not tied to models, extending the built-in admin without replacing it entirely. It supports Django versions 3.0+ and Python 3.7+. While the last official PyPI release was in 2016 (v0.6), the project is actively maintained with CI/CD testing against recent Django and Python versions.

Warnings

Install

Imports

Quickstart

To integrate `django-adminplus`, you need to modify your project's `settings.py` and `urls.py`. In `settings.py`, replace `'django.contrib.admin'` with `'django.contrib.admin.apps.SimpleAdminConfig'` and add `'adminplus'` to `INSTALLED_APPS`. In `urls.py`, replace `django.contrib.admin.site` with an instance of `AdminSitePlus` before calling `admin.autodiscover()`. Then, you can register any callable view using `admin.site.register_view`.

import os
import django
from django.conf import settings
from django.urls import path, include
from django.contrib import admin
from adminplus.sites import AdminSitePlus
from django.http import HttpResponse

settings.configure(
    DEBUG=True,
    SECRET_KEY=os.environ.get('DJANGO_SECRET_KEY', 'insecure-dev-key'),
    ROOT_URLCONF=__name__,
    INSTALLED_APPS=[
        'django.contrib.admin.apps.SimpleAdminConfig', # Replace default admin config
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'adminplus',
    ],
    TEMPLATES=[
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [],
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
                ],
            },
        },
    ],
    MIDDLEWARE_CLASSES=[
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ],
    DATABASES={
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': ':memory:',
        }
    },
    STATIC_URL='/static/',
)

django.setup()

# 1. Replace the default admin.site with AdminSitePlus
admin.site = AdminSitePlus()
admin.autodiscover()

# 2. Define your custom view
def my_custom_admin_view(request):
    return HttpResponse("Hello from a custom admin view!")

# 3. Register the custom view
admin.site.register_view('my-path', view=my_custom_admin_view, name='My Custom View')

# Include the admin URLs
urlpatterns = [
    path('admin/', admin.site.urls),
]

if __name__ == '__main__':
    # This block is for demonstration only and assumes a Django project setup
    # In a real project, you would run `python manage.py runserver`
    print("Django Admin Plus quickstart configured.")
    print("To run, you'd typically have this in your project's urls.py and settings.py.")
    print("Access custom view at: /admin/my-path/")

view raw JSON →