I'm using the following context processor to pass context to all my pages, except when the user is not logged in which case it takes him to the login page :
from django.conf import settings
from .models import foo
from django.shortcuts import redirect
def globalVar(request):
if not request.session.get('user_id') is None:
return {"foo": foo}
else:
return redirect('login')
But the redirect causes an exception for which i didn't find a fix :
ValueError: dictionary update sequence element #0 has length 0; 2 is required
Am i not looking in the right place, or is there a way to replace redirect by something else ?