简体   繁体   English

在Heroku之后Django Runserver无法正常工作

[英]Django runserver not working after Heroku

I've successfully posted my Django web app on Heroku. 我已成功将我的Django网络应用发布在Heroku上。 But now I want to run the server on my localhost. 但是现在我想在本地主机上运行服务器。 Earlier I could use "python manage.py runserver --insecure" but now I get the following error. 之前我可以使用“ python manage.py runserver --insecure”,但是现在出现以下错误。

shashank@s-machine:~/development/hellowebapp/hellowebapp$ python manage.py runserver
/usr/local/lib/python2.7/dist-packages/django/contrib/sites/models.py:78: RemovedInDjango19Warning: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Site(models.Model):

/usr/local/lib/python2.7/dist-packages/django/contrib/sites/models.py:78: RemovedInDjango19Warning: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Site(models.Model):

Performing system checks...

System check identified some issues:

WARNINGS:
registration.RegistrationProfile.user: (fields.W342) Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
    HINT: ForeignKey(unique=True) is usually better served by a OneToOneField.

System check identified 1 issue (0 silenced).
March 05, 2016 - 07:47:35
Django version 1.8.4, using settings 'hellowebapp.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Unhandled exception in thread started by <function wrapper at 0x7f569e30b668>
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 137, in inner_run
    handler = self.get_handler(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/runserver.py", line 24, in get_handler
    handler = super(Command, self).get_handler(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 55, in get_handler
    return get_internal_wsgi_application()
  File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 60, in get_internal_wsgi_application
    sys.exc_info()[2])
  File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 50, in get_internal_wsgi_application
    return import_string(app_path)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_string
    module = import_module(module_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/shashank/development/hellowebapp/hellowebapp/hellowebapp/wsgi.py", line 13, in <module>
    from whitenoise.django import DjangoWhiteNoise
django.core.exceptions.ImproperlyConfigured: WSGI application 'hellowebapp.wsgi.application' could not be loaded; Error importing module: 'No module named whitenoise.django'

Here is my WSGI.py 这是我的WSGI.py

"""
WSGI config for hellowebapp project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hellowebapp.settings_production")

application = get_wsgi_application()
application = DjangoWhiteNoise(application)

From the dumped error report it is clear to me that your problem is coming from lack of the the whitenoise module. 从转储的错误报告中,我很清楚您的问题是由于缺少白噪声模块引起的。 from the last line here >> 从最后一行开始>>

File "/home/shashank/development/hellowebapp/hellowebapp/hellowebapp/wsgi.py", 
line 13, in <module>
from whitenoise.django import DjangoWhiteNoise

django.core.exceptions.ImproperlyConfigured: WSGI application 
'hellowebapp.wsgi.application' could not be loaded; Error importing 
 module: 'No module named whitenoise.django'

First adivice: 第一处:

  1. Make sure that the Virtualenv you used is active, I am assuming that you have already installed the whitenoise package from pypi in that virtualenv. 确保您使用的Virtualenv是活动的,我假设您已经在该virtualenv中安装了pypi的whitenoise软件包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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