我正在尝试在Python Anywhere中获取基本网页。我无法查看“主页”页面。
我按照说明配置了WSGI
文件,并且该网站在我的Linux机箱上工作正常。
请帮忙!
这是我的wsgi.py
文件:
# +++++++++++ DJANGO +++++++++++
import os
import sys
## assuming your Django settings file is at '/home/my_username/projects/my_project /settings.py'
path = '/home/mickpc/solar_update'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'my_project.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
以下是错误代码的开头:
2014-12-10 03:29:04,746 :Traceback (most recent call last):
2014-12-10 03:29:04,746 : File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2014-12-10 03:29:04,747 : self.error_log_file.logger.exception("Error running WSGI application")
2014-12-10 03:29:04,747 : File "/usr/lib/python2.7/logging/__init__.py", line 1185, in exception
2014-12-10 03:29:04,747 : self.error(msg, *args, **kwargs)
2014-12-10 03:29:04,747 : File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error
2014-12-10 03:29:04,747 : self._log(ERROR, msg, args, **kwargs)
2014-12-10 03:29:04,747 : File "/usr/lib/python2.7/logging/__init__.py", line 1270, in _log
2014-12-10 03:29:04,747 : record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
2014-12-10 03:29:04,748 : File "/usr/lib/python2.7/logging/__init__.py", line 1244, in makeRecord
2014-12-10 03:29:04,748 : rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2014-12-10 03:29:04,748 : File "/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2014-12-10 03:29:04,748 : self.threadName = threading.current_thread().name
2014-12-10 03:29:04,748 : File "/usr/lib/python2.7/threading.py", line 1160, in currentThread
2014-12-10 03:29:04,748 : return _active[_get_ident()]
2014-12-10 03:29:04,749 : File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2014-12-10 03:29:04,749 : app_iterator = self.app(environ, start_response)
2014-12-10 03:29:04,749 : File "/usr/local/lib/python2.7/dist-packages/django /core/handlers/wsgi.py", line 250, in __call__
2014-12-10 03:29:04,749 : self.load_middleware()
2014-12-10 03:29:04,749 : File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 47, in load_middleware
2014-12-10 03:29:04,749 : raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2014-12-10 03:29:04,749 :django.core.exceptions.ImproperlyConfigured: Error importing middleware django.middleware.clickjacking: "No module named clickjacking"
我网站的树:
.
├── db.sqlite3
├── manage.py
├── myfig.png
├── mysite
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── settings.py
│ ├── settings.py~
│ ├── settings.pyc
│ ├── templates
│ │ ├── index.html
│ │ └── index.html~
│ ├── urls.py
│ ├── urls.py~
│ ├── urls.pyc
│ ├── wsgi.py
│ └── wsgi.pyc
├── newapp
│ ├── admin.py
│ ├── admin.pyc
│ ├── foo.png
│ ├── graph.py
│ ├── graph.py~
│ ├── graph.pyc
│ ├── Images
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── migrations
│ │ ├── __init__.py
│ │ └── __init__.pyc
│ ├── models.py
│ ├── models.pyc
│ ├── myfig.png
│ ├── templates
│ │ ├── green-business-graph.jpg
│ │ ├── HourlyProfileGraph.gif
│ │ ├── index.html
│ │ ├── index.html~
│ │ ├── pic_mountain.jpg
│ │ └── url
│ ├── tests.py
│ ├── urls.py
│ ├── urls.py~
│ ├── urls.pyc
│ ├── views.py
│ ├── views.py~
│ └── views.pyc
└── README.md
views.py(newapp)
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.http import HttpResponse
import graph
def index(request):
graph.generate()
urls.py(solar_update)
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
#url(r'^admin/', include(admin.site.urls)),
url(r'^home/$', include('newapp.urls')),
)
这是建议的wsgi.py:
# +++++++++++ DJANGO +++++++++++
import os
import sys
## assuming your Django settings file is at '/home/my_username/projects/my_project/settings.py'
path = '/home/my_username/projects'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'my_project.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
答案 0 :(得分:3)
项目的布局表明您使用的是比PythonAnywhere安装的版本更新的Django版本。我猜测(从迁移文件夹的存在)你正在使用1.7。如果你想在PythonAnywhere上使用Django 1.7,你必须使用virtualenv。 PythonAnywhere帮助页面中有说明。