summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-04-25 08:49:57 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-04-25 08:49:57 +0000
commit5dfe74f221f2e7c5dc7e5722bb322336c605c7b5 (patch)
tree3ea00f43a6159ebce55f357db1c2173d374f48ec /docs
parentd744a660c4e1872370e40f77eb7a9e8d106aa73b (diff)
Fixed #3185 -- Made values for login, logout and post-login redirect URLs
configurable. This is a combined patch from Vasily Sulatskov, Marc Fargas and Collin Grady. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5072 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/authentication.txt23
-rw-r--r--docs/settings.txt27
2 files changed, 39 insertions, 11 deletions
diff --git a/docs/authentication.txt b/docs/authentication.txt
index 01b218de65..f0902fad39 100644
--- a/docs/authentication.txt
+++ b/docs/authentication.txt
@@ -387,14 +387,15 @@ introduced in Python 2.4::
``login_required`` does the following:
- * If the user isn't logged in, redirect to ``/accounts/login/``, passing
- the current absolute URL in the query string as ``next``. For example:
+ * If the user isn't logged in, redirect to ``settings.LOGIN_URL``
+ (``/accounts/login/`` by default), passing the current absolute URL
+ in the query string as ``next``. For example:
``/accounts/login/?next=/polls/3/``.
* If the user is logged in, execute the view normally. The view code is
free to assume the user is logged in.
-Note that you'll need to map the appropriate Django view to ``/accounts/login/``.
-To do this, add the following line to your URLconf::
+Note that you'll need to map the appropriate Django view to ``settings.LOGIN_URL``.
+For example, using the defaults, add the following line to your URLconf::
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
@@ -405,9 +406,9 @@ Here's what ``django.contrib.auth.views.login`` does:
* If called via ``POST``, it tries to log the user in. If login is
successful, the view redirects to the URL specified in ``next``. If
- ``next`` isn't provided, it redirects to ``/accounts/profile/`` (which is
- currently hard-coded). If login isn't successful, it redisplays the login
- form.
+ ``next`` isn't provided, it redirects to ``settings.LOGIN_REDIRECT_URL``
+ (which defaults to ``/accounts/profile/``). If login isn't successful,
+ it redisplays the login form.
It's your responsibility to provide the login form in a template called
``registration/login.html`` by default. This template gets passed three
@@ -487,7 +488,7 @@ Logs a user out, then redirects to the login page.
**Optional arguments:**
* ``login_url``: The URL of the login page to redirect to. This
- will default to ``/accounts/login/`` if not supplied.
+ will default to ``settings.LOGIN_URL`` if not supplied.
``django.contrib.auth.views.password_change``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -569,7 +570,7 @@ successful login.
**Optional arguments:**
* ``login_url``: The URL of the login page to redirect to. This
- will default to ``/accounts/login/`` if not supplied.
+ will default to ``settings.LOGIN_URL`` if not supplied.
Built-in manipulators
---------------------
@@ -636,7 +637,7 @@ Note that ``user_passes_test`` does not automatically check that the ``User``
is not anonymous.
``user_passes_test()`` takes an optional ``login_url`` argument, which lets you
-specify the URL for your login page (``/accounts/login/`` by default).
+specify the URL for your login page (``settings.LOGIN_URL`` by default).
Example in Python 2.3 syntax::
@@ -680,7 +681,7 @@ parameter. Example::
my_view = permission_required('polls.can_vote', login_url='/loginpage/')(my_view)
As in the ``login_required`` decorator, ``login_url`` defaults to
-``'/accounts/login/'``.
+``settings.LOGIN_URL``.
Limiting access to generic views
--------------------------------
diff --git a/docs/settings.txt b/docs/settings.txt
index 35a6cc22e6..827ae55239 100644
--- a/docs/settings.txt
+++ b/docs/settings.txt
@@ -562,6 +562,21 @@ strings for translation, but the translation won't happen at runtime -- so
you'll have to remember to wrap the languages in the *real* ``gettext()`` in
any code that uses ``LANGUAGES`` at runtime.
+LOGIN_URL
+---------
+
+Default: ``'/accounts/login/'``
+
+The URL where requests are redirected for login, specially when using the
+`@login_required`_ decorator.
+
+LOGOUT_URL
+----------
+
+Default: ``'/accounts/logout/'``
+
+LOGIN_URL counterpart.
+
MANAGERS
--------
@@ -620,6 +635,16 @@ locales have different formats. For example, U.S. English would say
See `allowed date format strings`_. See also DATE_FORMAT, DATETIME_FORMAT,
TIME_FORMAT and YEAR_MONTH_FORMAT.
+LOGIN_REDIRECT_URL
+------------------
+
+Default: ``'/accounts/profile/'``
+
+The URL where requests are redirected after login when the
+``contrib.auth.login`` view gets no ``next`` parameter.
+
+This is used by the `@login_required`_ decorator, for example.
+
PREPEND_WWW
-----------
@@ -1012,6 +1037,8 @@ Also, it's an error to call ``configure()`` more than once, or to call
It boils down to this: Use exactly one of either ``configure()`` or
``DJANGO_SETTINGS_MODULE``. Not both, and not neither.
+.. _@login_required: ../authentication/#the-login-required-decorator
+
Error reporting via e-mail
==========================