Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#19632 closed Cleanup/optimization (fixed)

Sample code is wrong in page: "Using the Django authentication system"

Reported by: grossmanandy@… 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)

0001-Fixed-19632-Corrected-the-auth-documentation-concern.patch (896 bytes ) - added by Simon Charette 11 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Simon Charette, 11 years ago

Needs documentation: set
Owner: changed from nobody to Simon Charette
Status: newassigned
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

comment:2 by Simon Charette, 11 years ago

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.

comment:3 by Simon Charette, 11 years ago

Has patch: set

Added the doc fix.

comment:4 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In d90abcc9dad9b239e77aa67bfdd0c431072e2434:

[1.5.x] Fixed #19632 -- Bug in code sample.

Thanks grossmanandy at bfusa com and Simon Charette.

Backport of 1dd7492.

comment:5 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

In 1dd749284325ea8fe747a3728ed92bafef4ff6a0:

Fixed #19632 -- Bug in code sample.

Thanks grossmanandy at bfusa com and Simon Charette.

comment:6 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

In d90abcc9dad9b239e77aa67bfdd0c431072e2434:

[1.5.x] Fixed #19632 -- Bug in code sample.

Thanks grossmanandy at bfusa com and Simon Charette.

Backport of 1dd7492.

Note: See TracTickets for help on using tickets.
Back to Top