1👍
✅
You can include this in your <head>
:
<script>var logged_in={{ request.user.is_authenticated|lower }};</script>
If you want information on the user that you can use in multiple usecases you can add this to urls.py:
urlpatterns += patterns('', url(r'^loggedinuser/$'),
lambda r:'{"is_logged_in":"%s"}'%r.user.is_authenticated)
You can of course expand upon this, add other features you want revealed.
Source:stackexchange.com