Skip to main content

A Django app make the admin public

Project description

django-public-admin-mixins

WARNING: Using this app may introduce security issues. We don't recommend using it in production. Use at you own risk.

This app helps developers create public interfaces using the django admin. That is, an interface where no login is required, and all users only have view permission on models.

There is another app, django-public-admin, which implements a similar funcionality, but uses child classes instead of mixins. For small admin projects it should be quicker to setup, but these mixins allow for more configurability.

Installation

  1. $ pip install django-public-admin-mixins
  2. Add public_admin to you INSTALLED_APPS, before django.contrib.admin

Usage

To make the admin interface public, one must configure both the admin site and the ModelAdmin classes that are registered to that site. For that, django-public-admin-mixins exposes two mixins: PublicAdminSiteMixin and PulbicModelAdminMixin. To use the former, one must use a custom admin site. More details can be found here, but the basic idea for overriding the default admin site is as follows:

# myproject/admin.py

from django.contrib import admin

from django_public_admin.admin import PublicAdminSiteMixin


class PublicAdminSite(PublicAdminSiteMixin, admin.AdminSite):
    pass
# myproject/apps.py

from django.contrib.admin.apps import AdminConfig


class PublicAdminConfig(AdminConfig):
    default_site = "myproject.admin.PublicAdminSite"
# myproject/settings.py

INSTALLED_APPS = [
    # ...
    "myproject.apps.PublicAdminConfig",  # replaces 'django.contrib.admin'
    # ...
]

When registering a model to this admin site, use a custom model admin which uses our mixin:

# myapp/admin.py

from django.contrib import admin

from django_public_admin.admin import PublicModelAdminMixin

from .models import MyModel

class PublicModelAdmin(PublicModelAdminMixin, admin.ModelAdmin):
    pass

admin.site.register(MyModel, PublicModelAdmin)

Templates

This app ships with templates to override links in the head of the site that aren't suited to a public admin, like the ones for login and logout. If you decide to use your own, there is no need to add the app to the INSTALLED_APPS list.

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_mixins-0.0.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_public_admin_mixins-0.0.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file django_public_admin_mixins-0.0.1.tar.gz.

File metadata

File hashes

Hashes for django_public_admin_mixins-0.0.1.tar.gz
Algorithm Hash digest
SHA256 01bd25837cc86770455e3f093f71aae233f003765d536be6ab9cdaaaa40615c4
MD5 439d147d8f35a131266519c159512e5a
BLAKE2b-256 73b8fdddcc59a0e731ac743757bd3f9c78d9cad4ebfce80b72009c87b0367789

See more details on using hashes here.

File details

Details for the file django_public_admin_mixins-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_public_admin_mixins-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b4e366bb4ac9ec1b29750bb8e23fde20706977a0869db207ebfa9435f76ee013
MD5 3ee0217d2d4222b48d58b24818cb0e6b
BLAKE2b-256 ff00ccdc62dc8c54f8c387953ef0a018db13af2864f50bb2eb14528cb4497f57

See more details on using hashes here.

Supported by

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