
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
django-env-overrides
Advanced tools
Override arbitrary Django settings via environment variables.
::
pip install django-env-overrides
django-env-overrides lets you quickly adjust an existing Django app to load arbitrary settings from environment variables.
Add these lines to the end of your setup.py
file:
::
import django_env_overrides
django_env_overrides.apply_to(globals())
Any environment variable prefixed with DJANGO__
will now be imported to your settings.
settings.py:
::
DEBUG = True
MEDIA_URL = '/media/'
DATABASES = {
'default': {
'ENGINE': 'sqlite3',
}
}
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
]
}
}
]
import django_env_overrides
django_env_overrides.apply_to(globals())
Environment:
::
DJANGO__SECRET_KEY=secret
DJANGO__MEDIA_URL=/new_url/
DJANGO__bool__DEBUG=False
POSTGRES=postgres://uf07k1:wegauwhg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722
DJANGO__db__DATABASES__default=$POSTGRES
DJANGO__TEMPLATES__0__OPTIONS__context_processors__1='my.context.processor'
Result:
::
DEBUG = False
MEDIA_URL = '/new_url/'
SECRET_KEY = 'secret'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'd8r82722',
'HOST': 'ec2-107-21-253-135.compute-1.amazonaws.com',
'USER': 'uf07k1',
'PASSWORD': 'wegauwhg',
'PORT': 5431,
}
}
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'my.context.processor',
]
}
}
]
The general format for environment variable names is:
<prefix>__<typecast>__<path>__<to>__<target>__<setting>
<prefix>
defaults to DJANGO
. If you want to use another prefix, use django_env_overrides.apply_to(globals(), prefix="MYPREFIX")
.
<typecast>
(optional) is any type known to the django-environ package <https://github.com/joke2k/django-environ#supported-types>
_.
Currently the supported types are str, bool, int, float, json, list, tuple, dict, url, path, db_url, cache_url, search_url, and email_url.
See the django-environ package for usage.
<typecast>
is optional and defaults to str
.
<path>__<to>__<target>__<setting>
specifies the setting or subsetting the value should be assigned to. Path elements
are treated as array indexes if they are integers, and otherwise as dictionary keys.
See CONTRIBUTING.rst
FAQs
Override arbitrary Django settings via environment variables.
We found that django-env-overrides demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.