summaryrefslogtreecommitdiff
path: root/docs/topics
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-03-31 23:34:03 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-03-31 23:34:03 +0000
commit516051bfd2b537f441c46359cce7eacbf15fc4b8 (patch)
treec518cb5727dcbbdeec08bf849e94bdfa7b5e36a7 /docs/topics
parent15becf23a9e4c9b230745738d2d42f6ab8f0f031 (diff)
A whole lotta documentation fixes: Fixes #8704, #8826, #8980, #9243, #9343, #9529,
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10303 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics')
-rw-r--r--docs/topics/auth.txt47
-rw-r--r--docs/topics/http/shortcuts.txt2
-rw-r--r--docs/topics/http/urls.txt34
-rw-r--r--docs/topics/testing.txt9
4 files changed, 82 insertions, 10 deletions
diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt
index c42388f393..15d0b39856 100644
--- a/docs/topics/auth.txt
+++ b/docs/topics/auth.txt
@@ -463,6 +463,12 @@ When a user profile model has been defined and specified in this manner, each
instance of the user profile model associated with that
:class:`~django.contrib.auth.models.User`.
+The method :class:`~django.contrib.auth.models.User.get_profile()`
+does not create the profile, if it does not exist. You need to
+register a handler for the signal
+:attr:`django.db.models.signals.post_save` on the User model, and, in
+the handler, if created=True, create the associated user profile.
+
For more information, see `Chapter 12 of the Django book`_.
.. _Chapter 12 of the Django book: http://www.djangobook.com/en/1.0/chapter12/#cn222
@@ -745,7 +751,7 @@ the following line to your URLconf::
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
- <form method="post" action="">
+ <form method="post" action="{% url django.contrib.auth.views.login %}">
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
@@ -868,6 +874,34 @@ includes a few other useful built-in views located in
* ``login_url``: The URL of the login page to redirect to. This will
default to :setting:`settings.LOGIN_URL <LOGIN_URL>` if not supplied.
+.. function:: password_reset_confirm(request[,uidb36, token, template_name, token_generator, set_password_form, post_reset_redirect])
+
+ Presents a form for entering a new password.
+
+ **Optional arguments:**
+
+ * ``uidb36``: The user's id encoded in base 36. This will default to
+ ``None``.
+ * ``token``: Token to check that the password is valid. This will default to ``None``.
+ * ``template_name``: The full name of a template to display the confirm
+ password view. Default value is :file:`registration/password_reset_confirm.html`.
+ * ``token_generator``: Instance of the class to check the password. This
+ will default to ``default_token_generator``, it's an instance of
+ ``django.contrib.auth.tokens.PasswordResetTokenGenerator``.
+ * ``set_password_form``: Form that will use to set the password. This will
+ default to ``SetPasswordForm``.
+ * ``post_reset_redirect``: URL to redirect after the password reset
+ done. This will default to ``None``.
+
+.. function:: password_reset_complete(request[,template_name])
+
+ Presents a view that informs that the password has been changed very well.
+
+ **Optional arguments:**
+
+ * ``template_name``: The full name of a template to display the view.
+ This will default to :file:`registration/password_reset_complete.html`.
+
Built-in forms
--------------
@@ -1125,10 +1159,10 @@ The currently logged-in user and his/her permissions are made available in the
Users
-----
-The currently logged-in user, either a
-:class:`~django.contrib.auth.models.User` instance or an
-:class:`~django.contrib.auth.models.AnonymousUser` instance, is stored in the
-template variable ``{{ user }}``:
+When rendering a template :class:`~django.template.context.RequestContext`, the
+currently logged-in user, either a :class:`~django.contrib.auth.models.User`
+instance or an :class:`~django.contrib.auth.models.AnonymousUser` instance, is
+stored in the template variable ``{{ user }}``:
.. code-block:: html
@@ -1138,6 +1172,9 @@ template variable ``{{ user }}``:
<p>Welcome, new user. Please log in.</p>
{% endif %}
+This template context variable is not available if a ``RequestContext`` is not
+being used.
+
Permissions
-----------
diff --git a/docs/topics/http/shortcuts.txt b/docs/topics/http/shortcuts.txt
index 64633aae12..2bc35a3b9f 100644
--- a/docs/topics/http/shortcuts.txt
+++ b/docs/topics/http/shortcuts.txt
@@ -26,7 +26,7 @@ Required arguments
------------------
``template``
- The full name of a template to use.
+ The full name of a template to use or sequence of template names.
Optional arguments
------------------
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
index 0d0f9ac889..4248d4f02e 100644
--- a/docs/topics/http/urls.txt
+++ b/docs/topics/http/urls.txt
@@ -633,6 +633,40 @@ reverse such patterns.
be imported correctly. Do not include lines that reference views you
haven't written yet, because those views will not be importable.
+resolve()
+---------
+
+The :func:`django.core.urlresolvers.resolve` function can be used for resolving
+URL paths to the corresponding view functions. It has the following signature:
+
+.. currentmodule:: django.core.urlresolvers
+.. function:: resolve(path, urlconf=None)
+
+``path`` is the URL path you want to resolve. As with ``reverse()`` above, you
+don't need to worry about the ``urlconf`` parameter. The function returns the
+triple (view function, arguments, keyword arguments).
+
+For example, it can be used for testing if a view would raise a ``Http404``
+error before redirecting to it::
+
+ from urlparse import urlparse
+ from django.core.urlresolvers import resolve
+ from django.http import HttpResponseRedirect, Http404
+
+ def myview(request):
+ next = request.META.get('HTTP_REFERER', None) or '/'
+ response = HttpResponseRedirect(next)
+
+ # modify the request and response as required, e.g. change locale
+ # and set corresponding locale cookie
+
+ view, args, kwargs = resolve(urlparse(next)[2])
+ kwargs['request'] = request
+ try:
+ view(*args, **kwargs)
+ except Http404:
+ return HttpResponseRedirect('/')
+ return response
permalink()
-----------
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
index 974856b0c4..2de12390ad 100644
--- a/docs/topics/testing.txt
+++ b/docs/topics/testing.txt
@@ -138,10 +138,11 @@ and execute those lines while checking that the results match.
In the case of model tests, note that the test runner takes care of creating
its own test database. That is, any test that accesses a database -- by
creating and saving model instances, for example -- will not affect your
-production database. Each doctest begins with a "blank slate" -- a fresh
-database containing an empty table for each model. (See the section on
-fixtures, below, for more on this.) Note that to use this feature, the database
-user Django is connecting as must have ``CREATE DATABASE`` rights.
+production database. However, the database is not refreshed between doctests,
+so if your doctest requires a certain state you should consider flushin the
+database or loading a fixture. (See the section on fixtures, below, for more
+on this.) Note that to use this feature, the database user Django is connecting
+as must have ``CREATE DATABASE`` rights.
For more details about how doctest works, see the `standard library
documentation for doctest`_.