Best practices for Django database configuration?

From Carlton’s post at Settings refactor - #2 by carltongibson -

In addition to Django-environ, I was also thinking of goodconf and django-classy-settings. (I may have been aware of the other two, but they just didn’t come to mind when I wrote my post.)

It’s not “limitations”, it’s the benefits that justify it. When you directly access the environment variables, you get a string. Libraries such as django-environ can parse those strings and return specific data types. (Saving you the effort of writing that code.)

Snippet:

INSTALLED_APPS = [ 'app1', 'app2', 'app3']

if DEBUG:
    INSTALLED_APPS += 'app4'

(Or, if the position of the new app is important)

if DEBUG:
    INSTALLED_APPS.insert(2, 'app4')

(Or, if you need to install one of two different apps.)

if DEBUG:
    INSTALLED_APPS.insert(2, 'app4a')
else:
    INSTALLED_APPS.insert(2, 'app4b')

Anyway, that’s the basic idea.

As much as necessary.

In real terms, I don’t have that much that changes between environments.

I may have some debugging related apps or middleware for my development environment - possibly logging changes as well - but that’s about it.

1 Like