1👍
When you include __init__.py
in the folder, that folder is marked as a package called settings
, from which you can import modules like your local
module
This is a fairly standard thing in Python, even if not every Django programmer uses settings
as a package
From Python docs:
The
__init__.py
files are required to make Python treat the
directories as containing packages; this is done to prevent
directories with a common name, such as string, from unintentionally
hiding valid modules that occur later on the module search path. In
the simplest case,__init__.py
can just be an empty file, but it can
also execute initialization code for the package or set the__all__
variable, described later.
Source: https://docs.python.org/3/tutorial/modules.html#packages
my question is do I need to write from .local import * in init.py
for the package to work?
Check your manage.py
file it should load the settings.local
, e.g.
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings.local")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
Also check the actual value of SECRET_KEY
in the local module see if it is empty or not (if e.g. you use some variable interpolation)