Add a sub-section about env prefixing

This commit is contained in:
Radoslav Georgiev 2021-11-22 14:31:06 +02:00
parent f88c892296
commit cd7712e41e
No known key found for this signature in database
GPG Key ID: 0B7753A4DFCE646D

View File

@ -38,6 +38,7 @@ Django styleguide that we use in [HackSoft](https://hacksoft.io).
* [Advanced serialization](#advanced-serialization)
- [Urls](#urls)
- [Settings](#settings)
* [Prefixing environment variables with `DJANGO_`](#prefixing-environment-variables-with-django_)
* [Integrations](#integrations)
* [Reading from `.env`](#reading-from-env)
- [Errors & Exception Handling](#errors--exception-handling)
@ -1094,6 +1095,14 @@ from config.settings.celery import * # noqa
from config.settings.sentry import * # noqa
```
### Prefixing environment variables with `DJANGO_`
In a lot of examples, you'll see that environment variables are usually prefixed with `DJANGO_`. This is very helpful when there are other applications running alongside your Django app & reading from the same environment.
We tend to prefix with `DJANGO_` only `DJANGO_SETTINGS_MODULE` and `DJANGO_DEBUG` & not prefix everything else.
This is mostly up to personal preference. **Just make sure you are consistent with that.**
### Integrations
Since everything should be imported in `base.py`, but sometimes we don't want to configure a certain integration for local development, we derived the following approach: