access django session from a decorator
Posted
by ed1t
on Stack Overflow
See other posts from Stack Overflow
or by ed1t
Published on 2010-04-10T14:20:53Z
Indexed on
2010/04/10
14:23 UTC
Read the original article
Hit count: 443
I have a decorator that I use for my views @valid_session
from django.http import Http404
def valid_session(the_func):
"""
function to check if the user has a valid session
"""
def _decorated(*args, **kwargs):
if ## check if username is in the request.session:
raise Http404('not logged in.')
else:
return the_func(*args, **kwargs)
return _decorated
I would like to access my session in my decoartor. When user is logged in, I put the username in my session.
© Stack Overflow or respective owner