Giving support to the very well @trinchet's answer with an example of context_processor code.
Puts inside your webapp
a new file called context_processors.py
and writes this lines on it:
def user_groups(request):
"""
Add `groups` var to the context with all the
groups the logged in user has, so you can access
in your templates to this var as: {{ groups }}
"""
groups = None
if request.user.is_authenticated():
groups = user.groups
return {'groups': groups}
Finally on your settings.py
add 'webbapp.context_processors.user_groups'
to TEMPLATE_CONTEXT_PROCESSOR
:
TEMPLATE_CONTEXT_PROCESSORS = (
'webbapp.context_processors.user_groups',
)