Skip to content

Instantly share code, notes, and snippets.

@devStepsize
Created April 12, 2016 16:33
Show Gist options
  • Save devStepsize/b973eb82019816172a8d01dc4c85de72 to your computer and use it in GitHub Desktop.
Save devStepsize/b973eb82019816172a8d01dc4c85de72 to your computer and use it in GitHub Desktop.
Example authentication template in Django
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
@login_required
def my_protected_view(request):
"""A view that can only be accessed by logged-in users"""
return render(request, 'protected.html', {'current_user': request.user})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment