G
G
garasevn2021-03-24 16:05:47
Django
garasevn, 2021-03-24 16:05:47

How to setup postgresql database connection with different roles via django?

Several roles with different rights are created in the database. For example, unlogged_role is a role that has access to queries and inserts into the user table (an unlogged user can create an account or log in, respectively). There is a logged_role role, which has more extensive features.
Then the corresponding users are created in the database with the given roles.

create user unlogged_user with password '1';
grant unlogged_role to unlogged_user;

In code, the connection looks like this: The
605b3868f2fb8526149627.png
question is how to switch between these database users in the program.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2021-03-24
@garasevn

Write your manager

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question