Azure Django PostgreSQL deploy: Database migration does not work as it should

Nick Mol 1 Reputation point
2022-10-24T20:24:51.47+00:00

I am trying to deploy my Django App on Azure with python runtime 3.8 and a PostgreSQL database. I followed the tutorial on microsoft learn (using the web + database experience) , and have structured my app similar to the example.Including a migration of my database in the SSH portal.

I can visit the pages of my app which do not query the database. However, when I go to a page with a db query or the Django admin portal I get an error saying that there is a problem with relations or the database. This leads me to believe that the migration has not actually worked correctly.

I can't seem to figure out what is going wrong. I have tried to do the exact same process with the microsoft example and that works. I looked at my code, but I can't find what is wrong. My project code is stored here!.

In addition, the application logs don't specify a lot of info. It has probably something to do with the database,but I cant seem to figure out what is wrong and I don't know how I can see my PostgreSQL database schema in Azure. If anyone has suggestions, they are very welcome!

253645-knipsel.png

Azure Database for PostgreSQL
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,900 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Nick Mol 1 Reputation point
    2022-11-01T19:21:17.027+00:00

    Hi Geetha, I solved my issue. In the MSFT example in the tutorial they used a production.py file, which referenced WEBSITE_HOSTNAME as a standard environment variable to determine whether the app was in production. This was not working well, so I created a new settings file for production, and created my own environment variable to determine whether the app is in production or not. Thanks for the help!