从Eclipse运行django服务器时没有这样的表错误 [英] No such table error when running a django server from Eclipse

查看:118
本文介绍了从Eclipse运行django服务器时没有这样的表错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Django开发一个网站。当我通过命令提示符运行服务器时,如下所示:

  python manage.py runserver 

它运行正常,但是当我从Eclipse中执行它(右键单击项目 - > 运行为... - > django project ,我收到以下错误:


DatabaseError at /

否这样的表:django_session

请求方法:GET

请求URL: http:// localhost:8000 /

Django版本:1.3

异常类型:DatabaseError

异常值:

没有这样的表:django_session


有什么想法可以导致什么?不是那么精通django,所以我不知道什么文件可能导致这个 - 如果你需要我发布的东西,请在这里的意见。

解决方案

可能Eclipse / PyDev不是ab找到数据库。假设您使用sqlite3数据库,请在DATABASES设置中使用完整路径。通过控制台,然后在Eclipse中测试。这应该工作; - )



编辑:
建议使用photioionized,最好的方法是将这些行放在settings.py

  import os 
PROJECT_PATH = os.path.dirname(os.path.abspath(__ file__))

然后到

  SQLITE_3 = os。 path.join(PROJECT_PATH,你的DATABASE.DB)

SQLITE_3现在是您的完整路径sqlite3数据库,不管你的django项目的生活。


I'm developing a website using Django. When I run the server through the command prompt like so:

python manage.py runserver

it runs fine, but when I do it from Eclipse (right click on the project -> Run As... -> django project, I get the following error:

DatabaseError at /
no such table: django_session
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.3
Exception Type: DatabaseError
Exception Value:
no such table: django_session

Any ideas as to what can cause that? I'm not that proficient in django so I have no clue what file could be causing this - if you need me to post something, please ask here in the comments.

解决方案

Probably Eclipse/PyDev is not able to find the database. Assuming that you use a sqlite3 database, use a full path in the DATABASES settings. Test it via the console and afterwards within Eclipse. That should work ;-)

edit: As photioionized suggested, the best approach is to put those lines in settings.py

import os
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))

and then to

SQLITE_3 = os.path.join(PROJECT_PATH, 'YOUR DATABASE.DB')

SQLITE_3 is now the full path to your sqlite3 database, whereever your django project lives.

这篇关于从Eclipse运行django服务器时没有这样的表错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆