Loading docs/topics/auth/default.txt +2 −2 Original line number Diff line number Diff line Loading @@ -500,7 +500,7 @@ The simple way is to run your test on :attr:`request.user checks to make sure the user has an email in the desired domain:: def my_view(request): if not '@example.com' in request.user.email: if not request.user.email.endswith('@example.com'): return HttpResponse("You can't vote in this poll.") # ... Loading @@ -511,7 +511,7 @@ checks to make sure the user has an email in the desired domain:: from django.contrib.auth.decorators import user_passes_test def email_check(user): return '@example.com' in user.email return user.email.endswith('@example.com') @user_passes_test(email_check) def my_view(request): Loading Loading
docs/topics/auth/default.txt +2 −2 Original line number Diff line number Diff line Loading @@ -500,7 +500,7 @@ The simple way is to run your test on :attr:`request.user checks to make sure the user has an email in the desired domain:: def my_view(request): if not '@example.com' in request.user.email: if not request.user.email.endswith('@example.com'): return HttpResponse("You can't vote in this poll.") # ... Loading @@ -511,7 +511,7 @@ checks to make sure the user has an email in the desired domain:: from django.contrib.auth.decorators import user_passes_test def email_check(user): return '@example.com' in user.email return user.email.endswith('@example.com') @user_passes_test(email_check) def my_view(request): Loading