mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
[1.0.X] A whole lotta documentation fixes, backported from r10303 on trunk.
I got my commit message cut off the first try, but luckily I get to still thank Kevin Kubasik for rolling all these fixes up into a single easy patch. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10306 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -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
|
||||
-----------
|
||||
|
||||
|
||||
@@ -19,7 +19,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
|
||||
------------------
|
||||
|
||||
@@ -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()
|
||||
-----------
|
||||
|
||||
@@ -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`_.
|
||||
|
||||
Reference in New Issue
Block a user