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