#First make sure you have SessionMiddleware and AuthenticationMiddleware middlewares added to your MIDDLEWARE_CLASSES setting.
#The current user is in request object, you can get it by:
def sample_view(request):
current_user = request.user
print current_user.id
{% if user.is_superuser %}
<p>Hello, admin.</p>
{% else %}
<p>Hello, ordinary visitor.</p>
{% endif %}
user.is_superuser
from django.conf import settings
from django.shortcuts import redirect
def my_view(request):
if not request.user.is_authenticated:
return redirect('%s?next=%s' % (settings.LOGIN_URL, request.path))
# ...