Skip to content

Commit

Permalink
Fixed #4061: added docs on how to limit access to databrowse. Thanks,…
Browse files Browse the repository at this point in the history
… Nick Efford

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6201 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jacobian committed Sep 14, 2007
1 parent eea935a commit 74b816a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/databrowse.txt
Expand Up @@ -58,4 +58,29 @@ How to use Databrowse


4. Run the Django server and visit ``/databrowse/`` in your browser. 4. Run the Django server and visit ``/databrowse/`` in your browser.


Requiring user login
====================

You can restrict access to logged-in users with only a few extra lines of
code. Simply add the following import to your URLconf::

from django.contrib.auth.decorators import login_required

Then modify the URLconf so that the ``databrowse.site.root`` view is decorated
with ``login_required``::

(r'^databrowse/(.*)', login_required(databrowse.site.root)),

If you haven't already added support for user logins to your URLconf, as
described in the `user authentication docs`_, then you will need to do so
now with the following mapping::

(r'^accounts/login/$', 'django.contrib.auth.views.login'),

The final step is to create the login form required by
``django.contrib.auth.views.login``. The `user authentication docs`_
provide full details and a sample template that can be used for this
purpose.

.. _template loader docs: ../templates_python/#loader-types .. _template loader docs: ../templates_python/#loader-types
.. _user authentication docs: ../authentication/

0 comments on commit 74b816a

Please sign in to comment.