Reputation:
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
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