Django==1.6.5
argparse==1.2.1
dj-database-url==0.3.0
dj-static==0.0.5
django-toolbelt==0.0.1
gunicorn==18.0
psycopg2==2.5.3
pystache==0.5.4
static==1.0.2
wsgiref==0.1.2
hellodjango
├── hellodjango
│ ├── __init__.py
│ ├── settings.py
│ ├── settings.py~
│ ├── urls.py
│ ├── wsgi.py
│ └── wsgi.py~
└── manage.py
1 directory, 7 files
(venv)user@user-VirtualBox:~/Projects/projects/6.2.2014$ ls
hellodjango Procfile Procfile~ requirements.txt venv
2014-06-02T23:42:49.621172+00:00 app[web.1]: ImportError: No module named
hellodjango.wsgi
2014-06-02T23:42:49.621171+00:00 app[web.1]: __import__(module)
2014-06-02T23:42:49.621219+00:00 app[web.1]: 2014-06-02 23:42:49 [7] [INFO] Worker
exiting (pid: 7)
2014-06-02T23:42:49.790790+00:00 app[web.1]: 2014-06-02 23:42:49 [2] [INFO] Shutting
down: Master
2014-06-02T23:42:51.344028+00:00 heroku[web.1]: Process exited with status 3
2014-06-02T23:42:47.298345+00:00 heroku[web.1]: Starting process with command
`gunicorn hellodjango.wsgi`
2014-06-02T23:42:51.355014+00:00 heroku[web.1]: State changed from starting to
crashed
(venv)user@user-VirtualBox:~/Projects/projects/6.2.2014$
web: gunicorn hellodjango.wsgi -b 0.0.0.0:$PORT
有人能指出我在这里缺少的方向吗? 当Procfile只有这个时,我访问我的网站时遇到了同样的“应用程序错误”:
web: gunicorn hellodjango.wsgi
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
# I removed this line for the stack overflow posting SECRET_KEY = ''
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'gunicorn', #this wasn't here before, i added it and still got the application
# error
)
MIDDLEWARE_CLASSES = (
'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 = 'hellodjango.urls'
WSGI_APPLICATION = 'hellodjango.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
"""
# Internationalization
# https://docs.djangoproject.com/en/1.6/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/1.6/howto/static-files/
STATIC_URL = '/static/'
# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES['default'] = dj_database_url.config()
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Static asset configuration
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
import os
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hellodjango.settings")
application = Cling(get_wsgi_application())
答案 0 :(得分:0)
将其添加到您的.wsgi
文件
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
application = Cling(get_wsgi_application())
答案 1 :(得分:0)
将您的wsgi.py文件更改为:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hellodjango.settings")
from dj_static import Cling
application = Cling(get_wsgi_application())
您需要在导入Cling之前指定您的设置,否则会出错。