user6942230
user6942230

Reputation:

Django with PythonAnywhere -- Operational Error no such table

I am trying to run my django project on PythonAnywhere and keep getting the error

    "OperationalError at /
    no such table: analysis_predictions" 

when I go to my site. I am using sqlite3 and python 2.7. It seems like this is a common error and I have followed a bunch of instructions to try to fix it including adding the full file path to my database settings. When I try to run python manage.py migrate in the pythonanywhere bash console I get the error "OperationalError unable to open database file".

Settings.py:

   DATABASES = {
       'default': {
       'ENGINE': 'django.db.backends.sqlite3',
       'NAME':'/Users/Dahlia/learning_python/scifairserver/db.sqlite3',

       }
   }

Pythonanywhere console: img1

Current site: img2

Upvotes: 0

Views: 470

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 600059

As you can see from that screenshot, the path on Pythonanywhere is /home/dahlia/scifair, not /users/Dahlia/learning_python/scifair.

You shouldn't hard-code the path at all. Instead, use the BASE_DIR variable to calculate it:

'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

Upvotes: 1

Related Questions