I am just a beginner in django . I tried to create sub-domain by following this link. When I run my project it shows the following error
django.core.exceptions.ImproperlyConfigured: WSGI application 'netfacer.wsgi.application' could not be loaded; Error importing module.
my settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'dhxz$csco35cti*^kjru_lum-j*e&$el0rw^!$y0sc_$q8qi-x'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'django_hosts',
'subdomains',
'administrator.apps.AdministratorConfig',
'vendoruser.apps.VendoruserConfig',
'management.apps.ManagementConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django_hosts.middleware.HostsRequestMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'subdomains.middleware.SubdomainURLRoutingMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django_hosts.middleware.HostsResponseMiddleware',
]
SUBDOMAIN_URLCONF = {
'vendor':'netfacer.urls.vendor'
}
ROOT_URLCONF = 'netfacer.urls'
ROOT_HOSTCONF = 'netfacer.hosts'
DEFAULT_HOST = 'www'
DEFAULT_REDIRECT_URL = "http://www.netfacer.com:8000"
CUSTOM_URL = "netfacer.com:8000"
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.media',
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'netfacer.wsgi.application'
DATABASES = {
'default':{
'ENGINE' : 'django.db.backends.postgresql_psycopg2',
'NAME' : 'alpha',
'USER' : 'alpha',
'PASSWORD' : 'alpha',
'HOST' : 'localhost',
'PORT': ''
}
}
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',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
# '/assets/licences/your/images/outside/web/tree/'
]
ENV_PATH = os.path.abspath(os.path.dirname(__file__))
MEDIA_URL = '/assets/'
# MEDIA_URL = '/assets/'
MEDIA_ROOT = os.path.join(ENV_PATH, 'assets/')
# STATIC_ROOT = (os.path.join(BASE_DIR, 'static')
# MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
# MEDIA_URL = '/uploads/'
hosts.py
host_patterns = patterns('',
host(r'www', settings.ROOT_URLCONF, name='www'),
host(r'(?!www).*', 'netfacer.hostsconf.urls', name='wildcard'),
host(r'vendor', 'netfacer.hostsconf.urls', name="vendor")
)
also the documentation in the above link is confusing me
Typically you have to set
WSGI_APPLICATION
variable in your settings module, according to codenetfacer.wsgi.application
, package that containwsgi.py
is namednetfacer
. There may be next issues:netfacer
- check if you have renamed settings packagenetfacer
package is located in your<project_root>
directory, check if<project_root>
directory is part ofPYTHONPATH
environment variable