简体   繁体   中英

No such table error when running a django server from Eclipse

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.

For windows eclipse, It should be full path

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM