How do I reference a Django settings variable in my models.py? How do I reference a Django settings variable in my models.py? django django

How do I reference a Django settings variable in my models.py?


Try with this: from django.conf import settings thensettings.VARIABLE to access that variable.

VARIABLE should be in capital letter. It will not work otherwise.


from django.conf import settingsPRIVATE_DIR = getattr(settings, "PRIVATE_DIR", None)

Where it says None, you will put a default value incase the variable isn't defined in settings.