Skip to content Skip to sidebar Skip to footer

Django: Template Context Processor Request Variable

I am trying to implement django-facebookconnect, for I need to check if a user logged in via Facebook or a regular user. At the template, I can check if user logged in via facebook

Solution 1:

If you have access via the request object, why do you need to add a special is_facebook boolean at all? Just enable the built-in django.core.context_processors.request and this will ensure that request is present in all templates, then you can do this:

{% if request.facebook.uid %}

Solution 2:

It could be a timing issue. Make sure that the Common middleware comes before the facebook middleware in your settings file. You can probably debug and see when the facebook middleware is modifying the request and when your context processor is invoked. That may give you some clue as to why this is happening. But, as Daniel said, you can always just use the request object in your templates.

Post a Comment for "Django: Template Context Processor Request Variable"