Skip to main content

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.

Install

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

Usage

1. Create your Django Public Admin instance

Just like one would create a regular admin.py, 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):
    pass


class SnackModelAdmin(PublicModelAdmin):
    pass


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 urls.py, 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:

INSTALLED_APPS = [
    "public_admin",
    "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.

Contributing

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).

Release files for django-public-admin 0.0.1

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-public-admin 0.0.1
File Size Uploaded
django-public-admin-0.0.1.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-public-admin 0.0.1
File Interpreter ABI Platform
django_public_admin-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size:9.9 kB

Release files / django-public-admin-0.0.1.tar.gz

Download URL django-public-admin-0.0.1.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2abdb3ef3044abb989c51f018b5fcacac9fee8a2de2e867cc12da940d98b20ac
BLAKE2b-256 checksum
How to use checksums
2464da818ab1a1bbebf1cb5c93824663d1ebbf188cd5edbf4dd43b7b4068bff0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.2 Linux/4.19.0-8-amd64

Release files / django_public_admin-0.0.1-py3-none-any.whl

Download URL django_public_admin-0.0.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42a225e73589d582b336c26d9f7fb85efac62120e0969ca2179a55997c13ca93
BLAKE2b-256 checksum
How to use checksums
4e7931560765b0e3d756a66fda0862cb9d2e26817d868f48c05858ce94d0c997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.2 Linux/4.19.0-8-amd64

Release history Release notifications | RSS feed

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

This release

0.0.1 This release

2 release files

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