Skip to main content

A public read-only version of the Django Admin

Project description

Django Public Admin

A public and read-only version of the Django Admin. A drop-in replacement for Django's native AdminSite and ModelAdmin for publicly accessible data.

How does it work

  1. PublicAdminSite works as a clone of Django's native AdminSite, but it looks at the HTTP request and the URL to decide whether they should exist in a public and read-only dashboard.
  2. PublicModelAdmin work as a clone of Django's native ModelAdmin, but what it does is to stop actions that would create, edit or delete objects.
  3. DummyUser is just a an implementation detail, since Django requires an user to process the requests.


As this package is not finished nor published, this command does not work just yet. However, Poetry should install it in the local virtualenv one can access with poetry shell.

$ pip install django-public-admin


1. Create your Django Public Admin instance

Just like one would create a regular, you can create a module using Django Public Admin's PublicAdminSite and PublicModelAdmin:

from public_admin.admin import PublicModelAdmin
from public_admin.sites import PublicAdminSite, PublicApp

from my_website.my_open_house.models import Beverage, Snack

class BeverageModelAdmin(PublicModelAdmin):

class SnackModelAdmin(PublicModelAdmin):

public_app = PublicApp("my_open_house", models=("beverage", "snack"))
public_admin = PublicAdminSite(
    "dashboard",  # you name it as you wish
    public_app,  # this can be a single public app or a sequence of public apps
public_admin.register(Beverage, BeverageModelAdmin)
public_admin.register(Sanck, SanckModelAdmin)

2. Add your Django Public Admin URLs

In your, import the public_html (or whatever you've named it earlier) in your URLs file and create the endpoints:

from django.urls import path

from my_website.my_open_house.admin import public_admin

url = [
    # …
    path("dashboard/", public_admin.urls)

3. Templates

Django Public Admin comes with a template that hides from the UI elements related to user, login and logout. To use it, add public_admin to your INSTALLED_APPS before django.contrib.admin:

    # ...

If you decide not to use it, you have to create your own templates/base.html to avoid errors when rendering the template. Django will fail, for example, in rendering URLs that do not exist, which would be the case for login and logout.


We use tox to Run tests with Python 3.6, 3.7 and 3.8, and with Django 2 and 3. Also we use Black and flake8:

$ poetry install
$ poetry run tox

License & Credits

This package is licensed under MIT license and acknowledge Serenata de AmorOpen Knowledge Brasil and, previously, © Data Science Brigade).

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-public-admin-0.0.1.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

django_public_admin-0.0.1-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page