Django Get Settings Variable Example

Published On: 25/07/2022 | Category: Django Python

Hi Dev,

This article will provide some of the most important example python django get settings variable example. I explained simply step by step how to access variables from the settings folder. In this article, we will implement a access the value in settings django. you will learn django get environment variable.

So, access the value in settings django we can use settings.VARIABLE VARIABLE should be in capital letter otherwise not working.

Here, below describe the simple solution...

Solution: settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static', 'static_root')
Access to This Variable
from django.conf import settings
document_root=settings.STATIC_ROOT

I Hope It will help you....