Django can't see data anymore since db update

Hi,
I had some issues on my PgSQL database and had to export the data, delete the database, create a new one and import the data. Database name and user credentials stayed the same.
When I restart the development server of my Django project, no data is displayed neither on the public pages nor in the admin.
Yet no error message is displayed. It’s like it doesn’t see the data…
Any idea what could be the problem? Thanks!

Have you re-run your migrations?

Yep I have. I deleted the previous migrations and re-run them with --fake-initial.

Ok, so the problem is that Django doesn’t see the imported data?

Have you tried adding new data from some form?

Try doing a “manage.py dumpdata” on one of the known tables (perhaps your User table, perhaps a data table, or maybe try both) - that’s a quick test to verify that everything is working correctly with accessing your database.

Trying right now but I have a lot of new error messages that didn’t appear before. They highlight many errors in my models.py - it makes sense as I’m working with a legacy database and didn’t try yet to add new data. I need to sort it one message after the other. I will report the progress here.

manage.py dumpdata doesn’t output anything.

Ok, that’s a sign that your import didn’t work correctly. Whether the tables aren’t populated or you don’t have the right permissions set up, or you’re not using the right schema or what, we can’t tell from here.
The next best step I can think of is to use psql to connect to the database using the credentials that Django is configured to use to see what might be going wrong.

1 Like

I’m connected to the database through DBeaver, with the same credentials, and I can see the data. It might be the schema though. Is there a way to specify the schema in Django?

I know that it can be done, but I don’t remember how. We’ve just made it a point that all Django tables are in schema “public”.

OK! Thanks for your help. I’ll investigate and report back here :slight_smile:

All good! Data was imported into the wrong schema. I renamed the schema to public and the data appears again.
Thanks both for your help!