Take a default settings.py from an new project. Locate the requirements. txt and verify which one of the apps located there are django base and include them to the settings.py. Include all the apps explicitly defined on the project (all the folders different to the appname folder)
Create a settings.py file in your application's package (for example, if your application is named "myapp", put it in the filesystem directory named myapp ; the one with an __init__.py in it.
A Django settings file doesn't have to define any settings if it doesn't need to. Each setting has a sensible default value. These defaults live in the module django/conf/global_settings.py .
The settings.py is the central configuration for all Django projects. In previous chapters you already worked with a series of variables in this file to configure things like Django applications, databases, templates and middleware, among other things.
Try with this: from django.conf import settings
then
settings.VARIABLE
to access that variable.
VARIABLE should be in capital letter. It will not work otherwise.
from django.conf import settings
PRIVATE_DIR = getattr(settings, "PRIVATE_DIR", None)
Where it says None
, you will put a default value incase the variable isn't defined in settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With