17👍
✅
You certainly can… it’s encouraged, in fact. To use it, import the settings from django.conf (this imports your project’s settings):
from django.conf import settings
print "My database host is %s" % settings.DATABASE_HOST
The documentation on Using settings in Python code explains why this works, and why this is preferable over importing the the settings.py
module directly.
- [Django]-Errors When Installing MySQL-python module for Python 2.7
- [Django]-Django admin – how to display thumbnail instead of path to file
- [Django]-Adding days to a date via the ORM
- [Django]-POSTing foreign keys to Django Rest Framework, using Postman
Source:stackexchange.com