Tables missing in SQLite but viewable in admin (confusion)

325 views
Skip to first unread message

Ryan Kite

unread,
May 28, 2021, 7:56:17 PM5/28/21
to Django users
Greetings!

Am very confused about why the local dev SQLite DB 'appears' to be missing several tables.

In the Django Admin they exist and have data. 

I would be expecting to see the following tables in the DB but can't find them.
(These are the model names since I don't know what the table name look like yet.) 
  • Model: Allergies | Table: ?
  • Model: DoctorsAndProviders | Table: ?
  • Model: FamilyContacts | Table: ?
  • Model: PastSurgicalHistory | Table: ?
  • Model: HealthProfile | Table: ?
But, I do see these two models with their tables in the DB
  • Model: Med | Table: meds
  • Model: PastMedicalHistory  | Table: past_med_hx

The application seems to be working for the most part, we can still add and remove objects. But was encountering errors when trying to build a ForeignKey from the Allergies model to the HealthProfile Model that lives under the Users app. The error said something along the lines about the ID did not exist in the table? Which caused me to view the DB and notice this. 

Any help appreciated :)

screenshots attached.


admin.png
sqlite.png
content-type.png

Mottaz Hegaze

unread,
May 28, 2021, 8:02:37 PM5/28/21
to Django users
Maybe those are not migrated yet,
make sure that all your apps are added to installed_apps list in settings.py , run makemigrations and migrate

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9f7fecd6-b152-4e6d-8a9e-d22508b9d975n%40googlegroups.com.

Ryan Kite

unread,
May 28, 2021, 8:32:46 PM5/28/21
to Django users
Thanks for responding. 
Here is a screenshot showing them all added to installed apps and also a screenshot of the latest migration from an hour ago.
installed_apps.png
latest_migrate.png

Antonis Christofides

unread,
May 29, 2021, 5:59:44 AM5/29/21
to django...@googlegroups.com

The table name by default has the app name prepended; so the table for PastSurgicalHistory will be named superhealth_pastsurgicalhistory (assuming that your app is named superhealth).

Other than that, I'd make absolutely sure that the database I'm examining with the sqlite3 command (or whatever tool you have) is really the same as the one that is being read by Django. E.g. move the database file somewhere else (and restart Django) and make sure that the data in Django admin is gone.

Antonis Christofides
+30-6979924665 (mobile)

Ryan Kite

unread,
May 29, 2021, 5:54:30 PM5/29/21
to Django users
Thanks, Antonis, you were correct. The app was not actually using the SQLite DB it was using a different one that was not on the local machine. 
Reply all
Reply to author
Forward
0 new messages