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
PublicAdminSiteworks as a clone of Django's nativeAdminSite, but it looks at the HTTP request and the URL to decide whether they should exist in a public and read-only dashboard.PublicModelAdminwork as a clone of Django's nativeModelAdmin, but what it does is to stop actions that would create, edit or delete objects.DummyUseris 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 Amor (© Open Knowledge Brasil and, previously, © Data Science Brigade).
Metadata
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-public-admin-0.0.1.tar.gz | 4.7 kB | Without provenance | Details for django-public-admin-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_public_admin-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for django_public_admin-0.0.1-py3-none-any.whl |
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
|
Security for django-public-admin 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.