Here is my view. Basically, it returns different answers based on whether they are logged in or not.
@check_login()
def home(request):
if is_logged_in(request):
return x
else:
return y
Here is my decorator code. I just want to check if the request has headers, and if so, write it down.
def check_login():
def check_dec(func):
if request.META['username'] == "blah":
login(request, user)
return check_dec
The problem is that I do not know how to write the correct decorator in this case !!! What are the arguments? What are the features? How?
source
share