Forums

cannoot use commands from manage.py ModuleNotFoundError: No module named 'config.settings'

Hey can anybody help?

I haave my app deployed, but I tried to change my db to posgress and since the changes, now i cannot do python manage.py <command>

here my db settings, I have thhe new one commented in order to my app to work.

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } ---NEW DB--- '''DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'dbName', 'USER': 'dbUserName', 'PASSWORD': 'password', 'HOST': 'possgress URL', 'PORT': XXXX, } }'''

here my wsgi.py

import os import sys

from dotenv import load_dotenv

project_folder = os.path.expanduser('~/home/VictorOCP/Web_Ohana/Web Developments Proyects/OCP/src/skills_tutor') # adjust as appropriate

load_dotenv(os.path.join(project_folder, '.env'))

path = '/home/VictorOCP/Web_Ohana/Web Developments Proyects/OCP/src/skills_tutor' #project´s dir if path not in sys.path: sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'skills_tutor.settings'

from django.core.wsgi import get_wsgi_application application = get_wsgi_application()

here the error: ModuleNotFoundError: No module named 'config.settings'

You've left out the stacktrace that leads to the error and that has the information that we need to help you. Include the full stacktrace from your error log.

I am having the same error with my application. Here is the error log;

2022-10-18 06:10:14,659: Error running WSGI application
2022-10-18 06:10:14,681: ModuleNotFoundError: No module named 'config'
2022-10-18 06:10:14,681:   File "/home/<username>/.virtualenvs/<virtualenv_name>/lib/python3.10/site-packages/django/core/handlers/wsgi.py", line 131, in __call__
2022-10-18 06:10:14,681:     response = self.get_response(request)
2022-10-18 06:10:14,681: 
2022-10-18 06:10:14,682:   File "/home/<username>/.virtualenvs/<virtualenv_name>/lib/python3.10/site-packages/django/core/handlers/base.py", line 140, in get_response
2022-10-18 06:10:14,682:     response = self._middleware_chain(request)
2022-10-18 06:10:14,682: 
2022-10-18 06:10:14,682:   File "/home/<username>/.virtualenvs/<virtualenv_name>/lib/python3.10/site-packages/django/core/handlers/exception.py", line 57, in inner
2022-10-18 06:10:14,682:     response = response_for_exception(request, exc)
2022-10-18 06:10:14,682: 
2022-10-18 06:10:14,682:   File "/home/<username>/.virtualenvs/<virtualenv_name>/lib/python3.10/site-packages/django/core/handlers/exception.py", line 140, in response_for_exception
2022-10-18 06:10:14,682:     response = handle_uncaught_exception(
2022-10-18 06:10:14,683: 
2022-10-18 06:10:14,683:   File "/home/<username>/.virtualenvs/<virtualenv_name>/lib/python3.10/site-packages/django/core/handlers/exception.py", line 184, in handle_uncaught_exception
2022-10-18 06:10:14,683:     callback = resolver.resolve_error_handler(500)
2022-10-18 06:10:14,683: 
2022-10-18 06:10:14,683:   File "/home/<username>/.virtualenvs/<virtualenv_name>/lib/python3.10/site-packages/django/urls/resolvers.py", line 729, in resolve_error_handler
2022-10-18 06:10:14,683:     callback = getattr(self.urlconf_module, "handler%s" % view_type, None)
2022-10-18 06:10:14,683: 
2022-10-18 06:10:14,684:   File "/home/<username>/.virtualenvs/<virtualenv_name>/lib/python3.10/site-packages/django/utils/functional.py", line 57, in __get__
2022-10-18 06:10:14,684:     res = instance.__dict__[self.name] = self.func(instance)
2022-10-18 06:10:14,684: 
2022-10-18 06:10:14,684:   File "/home/<username>/.virtualenvs/<virtualenv_name>/lib/python3.10/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
2022-10-18 06:10:14,684:     return import_module(self.urlconf_name)

In my settings file, I added the config folder like this;

BASE_DIR = Path(__file__).resolve().parent.parent.parent
sys.path.append(str(BASE_DIR / 'config'))

What do you call a "settings" file exactly? Make sure that the paths are correct in the wsgi file that is linked to on the Web page.

My repository structure is like this:

| - <repo_name>
| - - config (this is a folder)
| - - - settings (this is a folder)
| - - - - base.py
| - - - - production.py (I was referring to this settings file. This imports other settings from base.py)
| - - - asgi.py
| - - - urls.py
| - - - wsgi.py
| - - <application_name>
| - - - app1 (this is a folder)
| - - - media (this is a folder)
| - - - static (this is a folder)
| - - - templates (this is a folder)
| - - requirements (this is a folder)
| - - manage.py
| - - <secret_file>.json

How do paths in your wsgi file look like? Maybe send it to support@pythonanywhere.com if you do not want to share it on public forums.

This problem continues. I shared the wsgi file with you. Thank you!

This problem is solved after the guidance was provided via your email. Thank you.

Glad to hear that!