Django: How/Where to store a value for a session without unnecessary DB hits
- by GerardJP
Hi all,
I have an extended userprofile with AUTH_PROFILE_MODULE (ref: http://tinyurl.com/yhracqq)
I would like to set a user.is_guru() method similar to user.is_active(). This would results for al views (or rather templates) to e.g. disable/enable certain user messages, displaying of widgets, etc. The boolean is stored in the extended user profile model, but I want to avoid hitting the DB for every view.
So the questions is .. Do I use a context_processor, a template tag, session_dict or what have you to, possible cached, store this info for the duration of the users visit.
Note: I dont have performance issues, so it's definitely filed under premature optimization. I just want to avoid generating extra work in the future :).
Any pointers are very welcome.
Thanx and greetz!
Gerard.