Django default settings convention for pluggable app?

I think it’s quite common to create a settings.py in your app’s package, where you define your settings like this:

from django.conf import settings
FOO = getattr(settings, 'FOO', "default_value")

In your app you can import them from your app’s settings module:

from myapp.settings import *

def print_foo():
    print FOO

But I think everybody agrees that Django is lacking a better generic architecture for this! If you’re looking for a more sophisticated way to handle this, there are some third party apps for this like django-appconf, but it’s your decision if you want to introduce one more dependency for your app or not!

Updated for 2020

In settings.py, put settings.* before the property.

from django.conf import settings
settings.FOO = getattr(settings, 'FOO', "default_value")

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)