Django

Code

Changeset 990

Show
Ignore:
Timestamp:
10/21/05 19:18:39 (3 years ago)
Author:
adrian
Message:

Some small improvements and fixes to docs/authentication.txt, which still isn't finished

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/authentication.txt

    r989 r990  
    5454    * ``is_superuser`` -- Boolean. Designates whether this user has permission 
    5555      to do anything (according to the permission system). 
    56     * ``last_login`` -- A datetime of the user's last login. Is set to "now" by 
    57       default. 
     56    * ``last_login`` -- A datetime of the user's last login. Is set to the 
     57      current date/time by default. 
    5858    * ``date_joined`` -- A datetime designating when the account was created. 
    59       Is set to "now" by default when the account is created. 
     59      Is set to the current date/time by default when the account is created. 
    6060 
    6161Methods 
     
    119119~~~~~~~~~~~~~~~~ 
    120120 
    121 The ``django.models.users`` module has the following helper functions: 
     121The ``django.models.auth.users`` module has the following helper functions: 
    122122 
    123123    * ``create_user(username, email, password)`` -- Creates, saves and returns 
     
    209209 
    210210    from django.utils.httpwrappers import HttpResponseRedirect 
     211 
    211212    def my_view(request): 
    212213        if request.user.is_anonymous(): 
     
    214215        # ... 
    215216 
    216 ...or displaying an error message:: 
     217...or display an error message:: 
    217218 
    218219    def my_view(request): 
     
    227228 
    228229    from django.views.decorators.auth import login_required 
     230 
    229231    def my_view(request): 
    230232        # ... 
    231233    my_view = login_required(my_view) 
    232234 
    233 Here's the same, using Python 2.4's decorator syntax:: 
     235Here's the same thing, using Python 2.4's decorator syntax:: 
    234236 
    235237    from django.views.decorators.auth import login_required 
     238 
    236239    @login_required 
    237240    def my_view(request): 
     
    264267 
    265268    from django.views.decorators.auth import user_passes_test 
     269 
    266270    @user_passes_test(lambda u: u.has_perm('polls.can_vote')) 
    267271    def my_view(request): 
     
    270274``user_passes_test`` takes a required argument: a callable that takes a 
    271275``User`` object and returns ``True`` if the user is allowed to view the page. 
     276Note that ``user_passes_test`` does not automatically check that the ``User`` 
     277is not anonymous. 
    272278 
    273279