11

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.

Zulu
  • 8,765
  • 9
  • 49
  • 56
Amir Rachum
  • 76,817
  • 74
  • 166
  • 248

2 Answers2

11

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.

jazz
  • 2,371
  • 19
  • 23
  • I'm developing with other people (using SVN). Using the full path would not allow them to work properly, wouldn't it? – Amir Rachum May 27 '11 at 20:37
  • 4
    There are some simple tricks to specifying something like an absolute path, I put `PROJECT_HOME=os.path.abspath(os.path.dirname(__file__))` and, under the db settings hash `'NAME': os.path.join(PROJECT_HOME,'database.db'),` in the settings.py file of pretty much every sqlite-based Django project I use... specifies an absolute file path (cross platform) based on the directory your settings.py is in... simplest way of doing everything IMO... – photoionized May 27 '11 at 21:12
0

For windows eclipse, It should be full path

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

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

Nilesh
  • 2,407
  • 1
  • 12
  • 20