A guide to setting up Django with PostgreSQL 15

Hello everyone,

I had a hell of a time last night setting up the brand new PostgreSQL 15 with Django. Some change made for security reasons in PG has made many tutorials and forum discussions obsolete and troubleshooting them has been… instructive.

To save you some trouble, I have put together a tutorial based on my findings. I hope it can be of help to somebody!

Any feedback is welcome,


Hello @axelbdt,

Thank you for the hard work, I was wondering, for a future production system, is it OK to go with a docker container and then build from there maybe a Debian OS + Postgres + Django in order to set up the backend?

I am planning to build a simple front-end based on bootstrap + backend Django + python + database e.g. Postgres, and I am not sure if the components listed here will be enough to accomplish the project.

The final project should be a simple system with a UI web application that can interact with a database and basically track projects perusers, have the option to query as many details via the UI, have an output about the status or progress of each user, and each project they own, some sort of dashboard, with a list of defined steps, and if one of the steps needs to be skipped, have options for special permission, with comments of why I want to start very basic and then later add more functionality.

Any comments or suggestions are much welcome.

Thank you,

I see where this is the second thread that you’ve commented on with this same request for information, suggestions, or ideas. Please don’t do that. (See FAQ - Django Forum)

Rather than tagging this on to multiple different topics, you may gain more traction by opening a new thread for this and see where it goes.


Sounds good, thank you for the suggestions, and apologies for the inconvenience.


Thanks for the heads up! This saved me a great headache while testing Postgresql 15.

I used a simpler approach, which should be avoided for most servers, but is worth pointing out. From the last bullet point of Section 5.9.6:

> * Keep the default search path, and grant privileges to create in the public schema. All users access the public schema implicitly. This simulates the situation where schemas are not available at all, giving a smooth transition from the non-schema-aware world. However, this is never a secure pattern. It is acceptable only when the database has a single user or a few mutually-trusting users. In databases upgraded from PostgreSQL 14 or earlier, this is the default.

This solution happens to be valid on our server, where there is a single user (no external users), and external SQL access is forbidden by firewall. Through psql:

GRANT CREATE ON SCHEMA public TO myUsername;

Any idea how this might work if you upgrade a database instance in place to 15? We’re running 14 right now. Everything currently sits in the public schema. I assume when we upgrade it will remain there. It seems accessing it there, without a super user, will not be possible. Are we literally going to have to move every single thing to a new schema?