#19632 closed Cleanup/optimization (fixed)
Sample code is wrong in page: "Using the Django authentication system"
| Reported by: | Owned by: | Simon Charette | |
|---|---|---|---|
| Component: | Documentation | Version: | 1.4 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | yes |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
In https://docs.djangoproject.com/en/dev/topics/auth/default/#auth-web-requests
from django.contrib.auth.decorators import user_passes_test
def email_check(user):
return '@example.com' in request.user.email
@user_passes_test(email_check)
def my_view(request):
...
should read
from django.contrib.auth.decorators import user_passes_test
def email_check(request):
return '@example.com' in request.user.email
@user_passes_test(email_check)
def my_view(request):
...
Attachments (1)
Change History (7)
comment:1 by , 13 years ago
| Needs documentation: | set |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Bug → Cleanup/optimization |
comment:2 by , 13 years ago
by , 13 years ago
| Attachment: | 0001-Fixed-19632-Corrected-the-auth-documentation-concern.patch added |
|---|
comment:4 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Actually looking at @user_passes_test the doc should read:
from django.contrib.auth.decorators import user_passes_test def email_check(user): return '@example.com' in user.email @user_passes_test(email_check) def my_view(request): ...Since the test function is called with
request.user.