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
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).
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-public-admin-0.0.1.tar.gz.
File metadata
- Download URL: django-public-admin-0.0.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/4.19.0-8-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2abdb3ef3044abb989c51f018b5fcacac9fee8a2de2e867cc12da940d98b20ac
|
|
| MD5 |
dcfdcfe4d2cca8ea1a93b47846af2771
|
|
| BLAKE2b-256 |
2464da818ab1a1bbebf1cb5c93824663d1ebbf188cd5edbf4dd43b7b4068bff0
|
File details
Details for the file django_public_admin-0.0.1-py3-none-any.whl.
File metadata
- Download URL: django_public_admin-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/4.19.0-8-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42a225e73589d582b336c26d9f7fb85efac62120e0969ca2179a55997c13ca93
|
|
| MD5 |
3cb58f7e30703a1288ba5ab264ddb097
|
|
| BLAKE2b-256 |
4e7931560765b0e3d756a66fda0862cb9d2e26817d868f48c05858ce94d0c997
|