user passes test django code example
Example 1: django login required decorator
from django.contrib.auth.decorators import login_required
@login_required
def my_view(request):
...
Example 2: user passes test django
from django.contrib.auth.decorators import user_passes_test
def email_check(user):
return user.email.endswith('@example.com')
@user_passes_test(email_check)
def my_view(request):
...