Django

Code

Changeset 6201

Show
Ignore:
Timestamp:
09/14/07 13:59:20 (1 year ago)
Author:
jacob
Message:

Fixed #4061: added docs on how to limit access to databrowse. Thanks, Nick Efford

Files:

Legend:

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

    r5866 r6201  
    5959    4. Run the Django server and visit ``/databrowse/`` in your browser. 
    6060 
     61Requiring user login 
     62==================== 
     63 
     64You can restrict access to logged-in users with only a few extra lines of 
     65code. Simply add the following import to your URLconf:: 
     66 
     67    from django.contrib.auth.decorators import login_required 
     68 
     69Then modify the URLconf so that the ``databrowse.site.root`` view is decorated 
     70with ``login_required``:: 
     71 
     72    (r'^databrowse/(.*)', login_required(databrowse.site.root)), 
     73 
     74If you haven't already added support for user logins to your URLconf, as 
     75described in the `user authentication docs`_, then you will need to do so 
     76now with the following mapping:: 
     77 
     78    (r'^accounts/login/$', 'django.contrib.auth.views.login'), 
     79 
     80The final step is to create the login form required by 
     81``django.contrib.auth.views.login``. The `user authentication docs`_ 
     82provide full details and a sample template that can be used for this 
     83purpose. 
     84 
    6185.. _template loader docs: ../templates_python/#loader-types 
     86.. _user authentication docs: ../authentication/