Skip to main content

Visually distinguish environments in Django Admin

Project description

django-admin-env-notice

Package Version Build Status Code Coverage

Visually distinguish environments in Django Admin. Based on great advice from post: 5 ways to make Django Admin safer by hakibenita.

Requirements

  • Python 2.7, 3.4+
  • Django 1.9+

Quickstart

Install django-admin-env-notice::

pip install django-admin-env-notice

Add it to your INSTALLED_APPS before django.contrib.admin:

INSTALLED_APPS = (
    ...
    'django_admin_env_notice',
    'django.contrib.admin',
    ...
)

Add context processor:

TEMPLATES = [
    {
        ...
        "OPTIONS": {
            "context_processors": [
                ...
                "django_admin_env_notice.context_processors.from_settings",
            ],
        },
    },
]

Set label and color for current environment:

ENVIRONMENT_NAME = "Production server"
ENVIRONMENT_COLOR = "#FF2222"

Override django admin selector if necessary (default: body), e.g: grappelli:

ENVIRONMENT_ADMIN_SELECTOR = "grp-header"

Optionally, set the environment banner to float over instead of being fixed to the top:

ENVIRONMENT_FLOAT = True

You can also set the text color (default: white) by setting:

ENVIRONMENT_TEXT_COLOR = "#00FF00"

You can stop showing the banner to unauthenticated users by setting (default: True):

ENVIRONMENT_SHOW_TO_UNAUTHENTICATED = False

Screenshots

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

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-admin-env-notice-1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

django_admin_env_notice-1.0-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-admin-env-notice-1.0.tar.gz.

File metadata

  • Download URL: django-admin-env-notice-1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for django-admin-env-notice-1.0.tar.gz
Algorithm Hash digest
SHA256 d7dbbcf5d020dd5dfe1aa987f5666407843dfb5db846df84ca68a92a3f9e3c6c
MD5 97774d02fb1bc42747bb1a48218dfc78
BLAKE2b-256 927ad2dd1f16dba7b570ba3e9709ea9011c559bfd03a897f24f0f7fadaae544d

See more details on using hashes here.

File details

Details for the file django_admin_env_notice-1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_env_notice-1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c7900bba2f61d7f6bbc3d778a4612601b80dd550f04f5dead35c48c44fbbc098
MD5 941c3891c51d4f536dda32fb469fa5e5
BLAKE2b-256 a297be7d6fb005ef3a661b31cf1059b710eab56fa7b34f3acfb1fdaa80f68734

See more details on using hashes here.

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