简体   繁体   中英

Internal Server Error heroku/django

I stack in heroku django tutorial after deploy project to heroku server. When I open heroku I have on website : Internal Server Error.

This is my heroku logs:

 2015-04-19T11:37:10.239891+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=secure-waters-8181.herokuapp.com request_id=6a5e44bf-4691-4207-9c8f-d2b18bf46a23 fwd="213.108.119.145" dyno=web.1 connect=2ms service=6ms status=500 bytes=244 2015-04-19T11:37:37.790381+00:00 heroku[router]: at=info method=GET path="/" host=secure-waters-8181.herokuapp.com request_id=25f8ea3a-a81d-45dd-a576-5ce58029b75e fwd="213.108.119.145" dyno=web.1 connect=0ms service=2ms status=500 bytes=244 2015-04-19T11:37:37.789336+00:00 app[web.1]: [2015-04-19 11:37:37 +0000] [9] [ERROR] Error handling request 2015-04-19T11:37:37.789341+00:00 app[web.1]: Traceback (most recent call last): 2015-04-19T11:37:37.789343+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 93, in handle 2015-04-19T11:37:37.789344+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2015-04-19T11:37:37.789346+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 134, in handle_request 2015-04-19T11:37:37.789347+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2015-04-19T11:37:37.789349+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/dj_static.py", line 83, in __call__ 2015-04-19T11:37:37.789351+00:00 app[web.1]: return self.application(environ, start_response) 2015-04-19T11:37:37.789354+00:00 app[web.1]: self.load_middleware() 2015-04-19T11:37:37.789356+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 44, in load_middleware 2015-04-19T11:37:37.789353+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 168, in __call__ 2015-04-19T11:37:37.789357+00:00 app[web.1]: mw_class = import_string(middleware_path) 2015-04-19T11:37:37.789358+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/module_loading.py", line 26, in import_string 2015-04-19T11:37:37.789360+00:00 app[web.1]: module = import_module(module_path) 2015-04-19T11:37:37.789361+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module 2015-04-19T11:37:37.789362+00:00 app[web.1]: __import__(name) 2015-04-19T11:37:37.789364+00:00 app[web.1]: ImportError: No module named security 

and this is my settings.py:

 # SECURITY WARNING: don't run with debug turned on in production! 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', ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', ) ROOT_URLCONF = 'hellodjango.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 = 'hellodjango.wsgi.application' # Database # https://docs.djangoproject.com/en/1.8/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.8/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.8/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') # Allow all host headers ALLOWED_HOSTS = ['*'] # 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'), ) 

I have to change something in database setting or I miss click when I doing tutorial ? I not have idea to fix it... ( sorry for my snippet format, I dont have idea to copy my code in diffrent way )

In the MIDDLEWARE_CLASSES of settings.py, you have 'django.middleware.security.SecurityMiddleware', , which is new in Django 1.8. Either make sure Heroku is using Django 1.8, or remove that line from MIDDLEWARE_CLASSES.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM