Ticket #4061: databrowse.diff

File databrowse.diff, 1.3 KB (added by nick@…, 17 years ago)

patch to Databrowse docs describing how to restrict access to logged-in users

  • docs/databrowse.txt

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