MattoTodd
MattoTodd

Reputation: 15219

modeling user settings in django

I would like have additional settings tied to each user in my application (beyond, is_staff, is_admin etc etc). Basically I'd like to have different settings to customize their user experience (ie: don't show tooltips, how many rows to display in results tables, other flags for turning things on or off).

Are there best practices for adding these types of settings, or example model to do this without touching the django user object (in the past when i needed a quick user property, i just added it to my django source code, but obviously know that this is a horrible idea).

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

I wasn't sure if there was a pretty way, or best practice for doing this.

Upvotes: 9

Views: 7448

Answers (2)

vad
vad

Reputation: 1276

As already said, use UserProfile. To store many flags in the same field there's django-bitfield.

Upvotes: 5

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799400

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

Upvotes: 0

Related Questions