Django在Apache/mod_wsgi上运行时出错

mar*_*lhc 2 python apache sqlite django mod-wsgi

最近我问了一个关于apache/mod_wsgi中识别python脚本目录的错误的问题.社区友好地回答了导致安装成功的问题.现在我有一个不同的错误,服务器守护进程(好吧,技术上是一个Windows服务,我说番茄你说...)没有找到任何模型,这里是完整的追溯:

环境:

Request Method: GET
Request URL: `http://localhost/polls/`
Django Version: 1.0.2 final
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'mysite.polls']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')
Run Code Online (Sandbox Code Playgroud)

模板错误:在模板c:\ users\marcos\documents\djangotemplates\polls\poll _list.html中,第1行的错误在渲染时捕获到异常:没有这样的表:polls_poll

       1 :  {% if object_list %}   
       2 :     <ul>  
       3 :     {% for poll in object_list %}  
       4 :          <li> <a href="{{poll.id}}/">{{ poll.question }} </a> </li>  
       5 :     {% endfor %}  
       6 :     </ul>  
       7 : {% else %}  
       8 :     <p>No polls are available.</p>  
       9 : {% endif %}  
       10 :   

追溯:

    File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in get_response
      86.                 response = callback(request, *callback_args, **callback_kwargs)
    File "C:\Python26\lib\site-packages\django\views\generic\list_detail.py" in object_list
          101.     return HttpResponse(t.render(c), mimetype=mimetype)
    File "C:\Python26\lib\site-packages\django\template\__init__.py" in render
          176.         return self.nodelist.render(context)
    File "C:\Python26\lib\site-packages\django\template\__init__.py" in render
          768.                 bits.append(self.render_node(node, context))
    File "C:\Python26\lib\site-packages\django\template\debug.py" in render_node
          81.             raise wrapped
Exception Type: TemplateSyntaxError at /polls/
Exception Value: Caught an exception while rendering: no such table: polls_poll
Run Code Online (Sandbox Code Playgroud)

有人建议我使用manage.py dbshel​​l并且脚本响应:
错误:您似乎没有安装'sqlite3'程序或在您的路径上.

但仍然是Django runserver完美地运行应用程序.我没有看到环境发生了什么变化,以至于如此努力地搞乱了网络应用程序.请帮忙!

S.L*_*ott 6

您没有数据库.目前尚不清楚为什么你没有sqlite3驱动程序.但是,您没有sqlite3,并且您没有数据库.

  1. 运行manage.py syncdb构建数据库.

    • 请务必使用与settings.py生产实例相同的内容.

    • 确保你settings.py有正确的驱动程序.您正在使用SQLite3,请确保使用绝对路径名.

    • 请务必使用与PYTHONPATH生产相同且工作的目录,以确保实际找到所有模块

  2. 运行普通SQL以查看您实际构建了数据库.

  3. 运行Django /admin应用程序以查看数据库中的内容.

SQLite3包含在Python中.为了丢失它,您的Python安装必须损坏或不完整.从头开始重新安装.