jazzband / dj-database-url

Use Database URLs in your Django Application.
https://pypi.org/project/dj-database-url/
BSD 3-Clause "New" or "Revised" License
1.49k stars 205 forks source link

How to add the schema to the URL? #211

Closed YAmikep closed 1 year ago

YAmikep commented 1 year ago

With PostgreSQL 15, we must add the following to the DB setting in django: (see this for more info)

        'OPTIONS': {
                'options': '-c search_path=myschema'
            },

I see that dj-database-url already has a way to add it but what is the syntax? For example, if I have postgres://USER:PASSWORD@HOST:PORT/NAME, how do I add the schema definition?

It would be nice to add this to the doc.

Thank you

YAmikep commented 1 year ago

Nevermind, I think I found the answer by looking at the tests. It seems to be the with ?currentSchema=otherschema.

It might still be worth adding it to the main doc now that more people will look for it with postgresql 15.