Operational Error: no such table
trent shipley
trent.shipley at gmail.com
Wed Feb 1 13:15:20 MST 2023
<Cross posted from the Django Users list with additions and clarifications.>
I am working on Precival's 2017 Test Driven Development with Python (and
Django) 2nd edition. I am stuck on chapter 9 which covers deployment to a
shared hosted or dedicated hosted remote development instance.
If I run on the local machine with ~/blah/blah/venv/bin/python3 manage.py
test functional_tests, then all the tests pass fine.
If I run on the remote host with python3 manage.py runserver 0.0.0.0:8000
and run the functional tests, the home page displays but it can't process
input failing with Operational Error: no such table.
I made a new sqlite3 migration and am told there is nothing new needing a
make migration. I apply migration, and nothing needs to be applied.
I'm thinking, "there is a difference in environments".
I try the same, running on my local machine with python3 manage.py
runserver and running the functional tests, and get the same failure as on
the remote shared host.
So now I think I have some file path weirdness. Maybe when run on the
Django development server instead of the Django testing tool, the path to
db.sqlite3 is different.
Googling suggests a simple make and apply sqlite3 migrations (which I've
tried), to using absolute file paths with usages to avoid having to change
paths between environments, to deleting the sqlite3 database and rebuild it
re-adding essential site data, like the Django superuser from scratch.
None of them mention any difference between running Django functional tests
directly from the Django tester (which works), and "injecting" a server (in
this case Django's own development server) directly into the functional
test script (which isn't working one either the local laptop or remote
server--they fail with the same Operational Error: no such table message.)
====
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
<snip/>
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
# Differs from example p. 147
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
Trent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phxlinux.org/pipermail/plug-discuss/attachments/20230201/f7d65867/attachment.htm>
More information about the PLUG-discuss
mailing list