views:

36

answers:

1

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.

+1  A: 

If you really want, you can use a cache session backend (beware that data might not persist, store the value somewhere else).

I really wouldn't be worried about avoiding hitting the database at an early stage, it's not difficult to rewire well written django applications.

Will Hardy