Tools that are needed BEFORE any others in each django project
Project description
django-before - tools that are needed BEFORE any others in each django project.
subpather
make_subpather - tool to calculate relative paths from root directory.
# at the beginning of settings.py
from django_before import make_subpather
# e.g. I have project structure where this file is here: project_root/src/django_project/settings/base.py
# so root of my project is 4 levels higher:
subroot = make_subpather(__file__, 4)
# know I can handy get paths relative to root of the project:
MEDIA_ROOT = subroot('static_content/media/')
DIR_SAMPLE_IMAGES = subroot('src/crm/res/sample_images')
json settings reader
make_json_settings_reader - tool to read settings from json file (e.g. secret settings).
# create settings reader
secrets = make_json_settings_reader(subroot('conf/secrets.json'))
# use it for reading settings
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydbname',
'USER': 'mydbuser',
'PASSWORD': secrets['DATABASE_PASSWORD'],
}
}
SECRET_KEY = secrets['SECRET_KEY']
Data in json file must be represented as dict:
{
"SECRET_KEY": "user123",
"DATABASE_PASSWORD": "user123"
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for django_before-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6efd5ce660206f566aa3b8ba47b8c507e4c065122639cc50e5d497e53339548 |
|
MD5 | 970f01abb54e35303c7767a76bb27f84 |
|
BLAKE2b-256 | 157abf7a2f44ca3aa20e4b31e8dd983067a2b8fb485720e3f9ca476221b3621e |