Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Added a password reset link to default admin login page if a password…

… reset URL is available.

You no longer have to override the admin login page just to get that link to

Also provided much better docs for how to plug in the provided password
reset mechanism with minimum effort.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 14ba0df commit 1c169071998702880b4fa534c06b35c20f184eef @spookylukey spookylukey committed
3  django/contrib/admin/static/admin/css/login.css
@@ -52,3 +52,6 @@ body.login {
padding: 1em 0 0 9.4em;
+.login .password-reset-link {
+ text-align: center;
7 django/contrib/admin/templates/admin/login.html
@@ -1,5 +1,6 @@
{% extends "admin/base_site.html" %}
{% load i18n admin_static %}
+{% load url from future %}
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />{% endblock %}
@@ -38,6 +39,12 @@
<input type="hidden" name="this_is_the_login_form" value="1" />
<input type="hidden" name="next" value="{{ next }}" />
+ {% url 'admin_password_reset' as password_reset_url %}
+ {% if password_reset_url %}
+ <div class="password-reset-link">
+ <a href="{{ password_reset_url }}">{% trans 'Forgotten your password or username?' %}</a>
+ </div>
+ {% endif %}
<div class="submit-row">
<label>&nbsp;</label><input type="submit" value="{% trans 'Log in' %}" />
5 docs/releases/1.4.txt
@@ -546,6 +546,11 @@ Django 1.4 also includes several smaller improvements worth noting:
For more details, see the documentation for
+* The admin login page will add a password reset link if you include a URL with
+ the name `'admin_password_reset'` in your, so plugging in the builtin
+ password reset mechanism and making it available is now much easier. For
+ details, see :ref:`auth_password_reset`.
Backwards incompatible changes in 1.4
28 docs/topics/auth.txt
@@ -371,6 +371,34 @@ Don't set the :attr:`~django.contrib.auth.models.User.password` attribute
directly unless you know what you're doing. This is explained in the next
+.. _auth_password_reset:
+User-requested password resets
+There is a bundled reset mechanism that integrates into the admin, allowing
+users to reset their passwords by email. It can be customized and is described
+in detail below under :func:`~django.contrib.auth.views.password_reset`. To
+enable it without customization, add lines something like the following to your
+.. code-block:: python
+ url(r'^admin/password_reset/$', 'django.contrib.auth.views.password_reset', name='admin_password_reset'),
+ (r'^admin/password_reset/done/$', 'django.contrib.auth.views.password_reset_done'),
+ (r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
+ (r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),
+(This assumes you've added the admin at ``admin/``, and requires that you put
+the URLs starting with ``^admin/`` before the line that includes the admin app
+.. versionchanged:: 1.4
+The presence of the 'admin_password_reset' named URL will cause a "forgotten
+your password?" link to appear on the default admin login page under the
+password box.
.. _auth_password_storage:
How Django stores passwords

0 comments on commit 1c16907

Please sign in to comment.
Something went wrong with that request. Please try again.