从 Eclipse 运行 django 服务器时没有这样的表错误

发布于 2024-11-10 11:01:00 字数 556 浏览 4 评论 0原文

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

python manage.py runserver

它运行良好,但是当我从 Eclipse 执行此操作时(右键单击项目 -> Run As... -> django 项目,出现以下错误:

数据库错误位于 /
没有这样的表:django_session
请求方法:GET
请求网址: http://localhost:8000/
Django 版本:1.3
异常类型:数据库错误
异常值:
没有这样的表:django_session

关于什么会导致这种情况有什么想法吗?我不太精通 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南街九尾狐 2024-11-17 11:01:00

Eclipse/PyDev 可能无法找到数据库。假设您使用 sqlite3 数据库,请在 DATABASES 设置中使用完整路径。通过控制台进行测试,然后在 Eclipse 中进行测试。那应该有效;-)

编辑:
正如 photioionized 所建议的,最好的方法是将这些行放在 settings.py 中

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

,然后

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

SQLITE_3 现在是 sqlite3 数据库的完整路径,无论您的 django 项目位于何处。

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.

怪异←思 2024-11-17 11:01:00

对于 Windows Eclipse,它应该是完整路径

for e.g. C:\\Abc.db

'\\' 应该代替单斜杠。

For windows eclipse, It should be full path

for e.g. C:\\Abc.db

'\\' should come in place of single slash.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文