Modeling user preferences in django

I would like to have additional settings associated with each user in my application (outside, is_staff, is_admin, etc. etc.). Basically, I would like to have different settings for customizing their user interface (i.e. Do not show tooltips, how many rows to display in the result tables, other flags for turning things on or off).

Are there any recommendations for adding these types of settings or an example model to do this without touching the django user object (in the past, when I needed a quick custom property, I just added it to my django source code, but obviously know that this terrible idea).

So, when someone successfully logs in, I would take the settings for the user and add them to the session.

I was not sure if it was a good way or if it was better for it.

+6
source share
2 answers

As already mentioned, use UserProfile . To save many flags in the same field, django-bitfield .

+3
source

Either put them in the user profile model, or create another model with a one-to-one User value.

0
source

Source: https://habr.com/ru/post/886745/


All Articles