Skip to main content

Django AdminPlus

AdminPlus aims to be the smallest possible extension to the excellent Django admin component that lets you add admin views that are not tied to models.

There are packages out there, like Nexus and django-admin-tools that replace the entire admin. Nexus supports adding completely new “modules” (the Django model admin is a default module) but there seems to be a lot of boiler plate code to do it. django-admin-tools does not, as far as I can tell, support adding custom pages.

All AdminPlus does is allow you to add simple custom views (well, they can be as complex as you like!) without mucking about with hijacking URLs, and providing links to them right in the admin index.

https://github.com/jsocol/django-adminplus/actions/workflows/ci.yml/badge.svg?branch=main

Installing AdminPlus

Install from PyPI with pip:

pip install django-adminplus

Or get AdminPlus from GitHub with pip:

pip install -e git://github.com/jsocol/django-adminplus#egg=django-adminplus

And add adminplus to your installed apps, and replace django.contrib.admin with django.contrib.admin.apps.SimpleAdminConfig:

INSTALLED_APPS = (
    'django.contrib.admin.apps.SimpleAdminConfig',
    # ...
    'adminplus',
    # ...
)

To use AdminPlus in your Django project, you’ll need to replace django.contrib.admin.site, which is an instance of django.contrib.admin.sites.AdminSite. I recommend doing this in urls.py right before calling admin.autodiscover():

# urls.py
from django.contrib import admin
from adminplus.sites import AdminSitePlus

admin.site = AdminSitePlus()
admin.autodiscover()

urlpatterns = [
    # ...
    # Include the admin URL conf as normal.
    (r'^admin', include(admin.site.urls)),
    # ...
]

Congratulations! You’re now using AdminPlus.

Using AdminPlus

So now that you’ve installed AdminPlus, you’ll want to use it. AdminPlus is 100% compatible with the built in admin module, so if you’ve been using that, you shouldn’t have to change anything.

AdminPlus offers a new function, admin.site.register_view, to attach arbitrary views to the admin:

# someapp/admin.py
# Assuming you've replaced django.contrib.admin.site as above.
from django.contrib import admin

def my_view(request, *args, **kwargs):
    pass
admin.site.register_view('somepath', view=my_view)

# And of course, this still works:
from someapp.models import MyModel
admin.site.register(MyModel)

Now my_view will be accessible at admin/somepath and there will be a link to it in the Custom Views section of the admin index.

You can also use register_view as a decorator:

@admin.site.register_view('somepath')
def my_view(request):
    pass

register_view takes some optional arguments:

  • name: a friendly name for display in the list of custom views. For example:

    def my_view(request):
        """Does something fancy!"""
    admin.site.register_view('somepath', 'My Fancy Admin View!', view=my_view)
  • urlname: give a name to the urlpattern so it can be called by redirect(), reverse(), etc. The view will be added to the admin namespace, so a urlname of foo would be reversed with reverse("admin:foo").

  • visible: a boolean or a callable returning one, that defines if the custom view is visible in the admin dashboard.

All registered views are wrapped in admin.site.admin_view.

Metadata

Release files for django-adminplus 0.6

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-adminplus 0.6
File Size Uploaded
django-adminplus-0.6.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-adminplus 0.6
File Interpreter ABI Platform
django_adminplus-0.6-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 19.3 kB

Release files / django-adminplus-0.6.tar.gz

Download URL django-adminplus-0.6.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
509635d3bc974c1cf1d2d151d5c690b81619a927eb431d758886cb52140b5eb9
BLAKE2b-256 checksum
How to use checksums
06f96196e5b09e18ca3efae5bdde9d894ccfa2bf0406f35181ba2b5d6af89d6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / django_adminplus-0.6-py2.py3-none-any.whl

Download URL django_adminplus-0.6-py2.py3-none-any.whl
Size 9.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4d1b201454feeea76a74d781d8ca69bcd6d0066399325ef63433e273e1f51882
BLAKE2b-256 checksum
How to use checksums
517f90e8f43b5e7fdc11f1e734239e6c5b302ee2ad270014c6e5482c8cb8d290
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.6 This release

2 release files

0.5

2 release files

0.4

2 release files

0.3

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

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