14👍
DJANGO_SETTINGS_MODULE
is expected to be a Python module identifier, not a filesystem path. Looking at the django/conf/__init__py
file, it seems that a relative path to your settings module won’t work there. You will need to move it below a directory listed in your sys.path
, or you should add a parent directory to your sys.path
and reference your settings module from there.
22👍
I came to this question via Google, so I’ll answer what helped me (not directly related to the question).
I use importlib
to dynamically import sub-packages given by a string.
import importlib
module_name = 'subpackage.i.import'
special_module = importlib.import_module(module_name, package=None)
This simply has to be adjusted to
import importlib
module_name = 'subpackage.i.import'
special_module = importlib.import_module(module_name, package='my_current_pkg')
- [Django]-Django — User.DoesNotExist does not exist?
- [Django]-Custom django admin templates not working
- [Django]-RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
1👍
You can also get this error simply if you have a typo in where you’re specifying your settings file name.
- [Django]-Can I use Django F() objects with string concatenation?
- [Django]-How to seed Django project ? – insert a bunch of data into the project for initialization
- [Django]-Django custom command not found
0👍
you need to add your project path to sys path just like
sys.path.append("C:\\Users\\ogward\\STUDPROJ")
os.environ['DJANGO_SETTINGS_MODULE'] = '../cloud_server.settings'
- [Django]-Is not JSON serializable
- [Django]-How to check if ManyToMany field is not empty?
- [Django]-Best practices for adding .gitignore file for Python projects?
-1👍
- may be the settings you set in uwsgi.py is not correct
-
the settings path in uwsgi.py(XXXX is in the same dir as uwsgi.py):
os.environ.setdefault(“DJANGO_SETTINGS_MODULE”, “XXXX.settings”)
- [Django]-Django : DRF Token based Authentication VS JSON Web Token
- [Django]-How to access request body when using Django Rest Framework and avoid getting RawPostDataException
- [Django]-How to stop gunicorn properly