1👍
✅
Django has already built login_required decorator for purpose of this
from django.contrib.auth.decorators import login_required
@login_required()
def some_view(request):
pass
If the user isn’t logged in, redirect to settings.LOGIN_URL
Source:stackexchange.com