Visually distinguish environments in Django Admin. Based on great advice from post: 5 ways to make Django Admin safer by hakibenita.
- Python 2.7, 3.4+
- Django 1.9+
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"
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Tools used in rendering this package: