我已成功在Heroku上发布了我的Django网络应用程序。但现在我想在我的localhost上运行服务器。早些时候我可以使用" 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'
这是我的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)
答案 0 :(得分:0)
从转储的错误报告中我很清楚,您的问题来自于缺少whitenoise模块。从这里的最后一行&gt;&gt;
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'
第一个建议: