Forums

Error running WSGI application

So I am getting WSGI error. It says you must configure this app with an AppConfig subclass with a 'path' class attribute. I think it has something to do with my installed apps in settings.py

> Error running WSGI application 2021-05-26 22:42:31,176:
> django.core.exceptions.ImproperlyConfigured: The app module <module
> 'accounts' (namespace)> has multiple filesystem locations
> (['/home/crmTool/crmTool/accounts', './accounts']); you must configure
> this app with an AppConfig subclass with a 'path' class attribute.
> 2021-05-26 22:42:31,176:   File
> "/var/www/crmtool_pythonanywhere_com_wsgi.py", line 14, in <module>
> 2021-05-26 22:42:31,176:     application = get_wsgi_application()
> 2021-05-26 22:42:31,176:  2021-05-26 22:42:31,176:   File
> "/home/crmTool/.virtualenvs/crmTool/lib/python3.8/site-packages/django/core/wsgi.py",
> line 12, in get_wsgi_application 2021-05-26 22:42:31,176:    
> django.setup(set_prefix=False) 2021-05-26 22:42:31,176:  2021-05-26
> 22:42:31,176:   File
> "/home/crmTool/.virtualenvs/crmTool/lib/python3.8/site-packages/django/__init__.py",
> line 24, in setup 2021-05-26 22:42:31,177:    
> apps.populate(settings.INSTALLED_APPS) 2021-05-26 22:42:31,177: 
> 2021-05-26 22:42:31,177:   File
> "/home/crmTool/.virtualenvs/crmTool/lib/python3.8/site-packages/django/apps/registry.py",
> line 91, in populate 2021-05-26 22:42:31,177:     app_config =
> AppConfig.create(entry) 2021-05-26 22:42:31,177:  2021-05-26
> 22:42:31,177:   File
> "/home/crmTool/.virtualenvs/crmTool/lib/python3.8/site-packages/django/apps/config.py",
> line 255, in create 2021-05-26 22:42:31,177:     return
> app_config_class(app_name, app_module) 2021-05-26 22:42:31,177: 
> 2021-05-26 22:42:31,177:   File
> "/home/crmTool/.virtualenvs/crmTool/lib/python3.8/site-packages/django/apps/config.py",
> line 49, in __init__ 2021-05-26 22:42:31,177:     self.path =
> self._path_from_module(app_module) 2021-05-26 22:42:31,178: 
> 2021-05-26 22:42:31,178:   File
> "/home/crmTool/.virtualenvs/crmTool/lib/python3.8/site-packages/django/apps/config.py",
> line 88, in _path_from_module 2021-05-26 22:42:31,178:     raise
> ImproperlyConfigured(

wsgi.py

import os
import sys

# assuming your django settings file is at '/home/crmTool/mysite/mysite/settings.py'
# and your manage.py is is at '/home/crmTool/mysite/manage.py'
path = '/home/crmTool/crmTool'
if path not in sys.path:
    sys.path.append(path)

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

# then:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

settings.py

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '...'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = ['http://crmtool.pythonanywhere.com/']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'accounts.apps.AccountsConfig',

    'django_filters',

]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'crm1.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'crm1.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'

MEDIA_URL = '/images/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]

MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images')

[edited by admin]

Do you have __init__.py file in your Django app folder? (BTW. please consider not posting your app's full configuration containing secret keys etc.)