Skip to content

Commit 5984117

Browse files
authored
Used .. attribute:: directive in authentication views docs.
1 parent 6ee86a1 commit 5984117

File tree

2 files changed

+185
-111
lines changed

2 files changed

+185
-111
lines changed

docs/ref/class-based-views/mixins-editing.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The following mixins are used to construct Django's editing views:
5151
.. method:: get_form_class()
5252

5353
Retrieve the form class to instantiate. By default
54-
:attr:`.form_class`.
54+
:attr:`~django.views.generic.edit.FormMixin.form_class`.
5555

5656
.. method:: get_form(form_class=None)
5757

docs/topics/auth/default.txt

Lines changed: 184 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -998,39 +998,50 @@ implementation details see :ref:`using-the-views`.
998998

999999
**Attributes:**
10001000

1001-
* ``template_name``: The name of a template to display for the view used to
1002-
log the user in. Defaults to :file:`registration/login.html`.
1001+
.. attribute:: template_name
10031002

1004-
* ``redirect_field_name``: The name of a ``GET`` field containing the
1005-
URL to redirect to after login. Defaults to ``next``.
1003+
The name of a template to display for the view used to log the user in.
1004+
Defaults to :file:`registration/login.html`.
10061005

1007-
* ``authentication_form``: A callable (typically a form class) to use for
1008-
authentication. Defaults to
1009-
:class:`~django.contrib.auth.forms.AuthenticationForm`.
1006+
.. attribute:: redirect_field_name
1007+
1008+
The name of a ``GET`` field containing the URL to redirect to after
1009+
login. Defaults to ``next``.
1010+
1011+
.. attribute:: authentication_form
1012+
1013+
A callable (typically a form class) to use for authentication. Defaults
1014+
to :class:`~django.contrib.auth.forms.AuthenticationForm`.
10101015

1011-
* ``extra_context``: A dictionary of context data that will be added to the
1012-
default context data passed to the template.
1016+
.. attribute:: extra_context
10131017

1014-
* ``redirect_authenticated_user``: A boolean that controls whether or not
1015-
authenticated users accessing the login page will be redirected as if
1016-
they had just successfully logged in. Defaults to ``False``.
1018+
A dictionary of context data that will be added to the default context
1019+
data passed to the template.
10171020

1018-
.. warning::
1021+
.. attribute:: redirect_authenticated_user
10191022

1020-
If you enable ``redirect_authenticated_user``, other websites will be
1021-
able to determine if their visitors are authenticated on your site by
1022-
requesting redirect URLs to image files on your website. To avoid
1023-
this "`social media fingerprinting
1024-
<https://robinlinus.github.io/socialmedia-leak/>`_" information
1025-
leakage, host all images and your favicon on a separate domain.
1023+
A boolean that controls whether or not authenticated users accessing
1024+
the login page will be redirected as if they had just successfully
1025+
logged in. Defaults to ``False``.
10261026

1027-
Enabling ``redirect_authenticated_user`` can also result in a redirect
1028-
loop when using the :func:`.permission_required` decorator
1029-
unless the ``raise_exception`` parameter is used.
1027+
.. warning::
10301028

1031-
* ``success_url_allowed_hosts``: A :class:`set` of hosts, in addition to
1032-
:meth:`request.get_host() <django.http.HttpRequest.get_host>`, that are
1033-
safe for redirecting after login. Defaults to an empty :class:`set`.
1029+
If you enable ``redirect_authenticated_user``, other websites will
1030+
be able to determine if their visitors are authenticated on your
1031+
site by requesting redirect URLs to image files on your website. To
1032+
avoid this "`social media fingerprinting
1033+
<https://robinlinus.github.io/socialmedia-leak/>`_" information
1034+
leakage, host all images and your favicon on a separate domain.
1035+
1036+
Enabling ``redirect_authenticated_user`` can also result in a
1037+
redirect loop when using the :func:`.permission_required` decorator
1038+
unless the ``raise_exception`` parameter is used.
1039+
1040+
.. attribute:: success_url_allowed_hosts
1041+
1042+
A :class:`set` of hosts, in addition to :meth:`request.get_host()
1043+
<django.http.HttpRequest.get_host>`, that are safe for redirecting
1044+
after login. Defaults to an empty :class:`set`.
10341045

10351046
Here's what ``LoginView`` does:
10361047

@@ -1137,22 +1148,33 @@ implementation details see :ref:`using-the-views`.
11371148

11381149
**Attributes:**
11391150

1140-
* ``next_page``: The URL to redirect to after logout. Defaults to
1141-
:setting:`settings.LOGOUT_REDIRECT_URL <LOGOUT_REDIRECT_URL>`.
1151+
.. attribute:: next_page
11421152

1143-
* ``template_name``: The full name of a template to display after
1144-
logging the user out. Defaults to :file:`registration/logged_out.html`.
1153+
The URL to redirect to after logout. Defaults to
1154+
:setting:`LOGOUT_REDIRECT_URL`.
11451155

1146-
* ``redirect_field_name``: The name of a ``GET`` field containing the
1147-
URL to redirect to after log out. Defaults to ``next``. Overrides the
1148-
``next_page`` URL if the given ``GET`` parameter is passed.
1156+
.. attribute:: template_name
1157+
1158+
The full name of a template to display after logging the user out.
1159+
Defaults to :file:`registration/logged_out.html`.
11491160

1150-
* ``extra_context``: A dictionary of context data that will be added to the
1151-
default context data passed to the template.
1161+
.. attribute:: redirect_field_name
1162+
1163+
The name of a ``GET`` field containing the URL to redirect to after log
1164+
out. Defaults to ``'next'``. Overrides the
1165+
:attr:`next_page` URL if the given ``GET`` parameter is
1166+
passed.
1167+
1168+
.. attribute:: extra_context
11521169

1153-
* ``success_url_allowed_hosts``: A :class:`set` of hosts, in addition to
1154-
:meth:`request.get_host() <django.http.HttpRequest.get_host>`, that are
1155-
safe for redirecting after logout. Defaults to an empty :class:`set`.
1170+
A dictionary of context data that will be added to the default context
1171+
data passed to the template.
1172+
1173+
.. attribute:: success_url_allowed_hosts
1174+
1175+
A :class:`set` of hosts, in addition to :meth:`request.get_host()
1176+
<django.http.HttpRequest.get_host>`, that are safe for redirecting
1177+
after logout. Defaults to an empty :class:`set`.
11561178

11571179
**Template context:**
11581180

@@ -1189,20 +1211,28 @@ implementation details see :ref:`using-the-views`.
11891211

11901212
**Attributes:**
11911213

1192-
* ``template_name``: The full name of a template to use for
1193-
displaying the password change form. Defaults to
1194-
:file:`registration/password_change_form.html` if not supplied.
1214+
.. attribute: template_name
1215+
1216+
The full name of a template to use for displaying the password change
1217+
form. Defaults to :file:`registration/password_change_form.html` if not
1218+
supplied.
11951219

1196-
* ``success_url``: The URL to redirect to after a successful password
1197-
change. Defaults to ``'password_change_done'``.
1220+
.. attribute:: success_url
11981221

1199-
* ``form_class``: A custom "change password" form which must accept a
1200-
``user`` keyword argument. The form is responsible for actually changing
1201-
the user's password. Defaults to
1202-
:class:`~django.contrib.auth.forms.PasswordChangeForm`.
1222+
The URL to redirect to after a successful password change. Defaults to
1223+
``'password_change_done'``.
12031224

1204-
* ``extra_context``: A dictionary of context data that will be added to the
1205-
default context data passed to the template.
1225+
.. attribute:: form_class
1226+
1227+
A custom "change password" form which must accept a ``user`` keyword
1228+
argument. The form is responsible for actually changing the user's
1229+
password. Defaults to
1230+
:class:`~django.contrib.auth.forms.PasswordChangeForm`.
1231+
1232+
.. attribute:: extra_context
1233+
1234+
A dictionary of context data that will be added to the default context
1235+
data passed to the template.
12061236

12071237
**Template context:**
12081238

@@ -1216,12 +1246,15 @@ implementation details see :ref:`using-the-views`.
12161246

12171247
**Attributes:**
12181248

1219-
* ``template_name``: The full name of a template to use.
1220-
Defaults to :file:`registration/password_change_done.html` if not
1221-
supplied.
1249+
.. attribute:: template_name
1250+
1251+
The full name of a template to use. Defaults to
1252+
:file:`registration/password_change_done.html` if not supplied.
1253+
1254+
.. attribute:: extra_context
12221255

1223-
* ``extra_context``: A dictionary of context data that will be added to the
1224-
default context data passed to the template.
1256+
A dictionary of context data that will be added to the default context
1257+
data passed to the template.
12251258

12261259
.. class:: PasswordResetView
12271260

@@ -1257,42 +1290,62 @@ implementation details see :ref:`using-the-views`.
12571290

12581291
**Attributes:**
12591292

1260-
* ``template_name``: The full name of a template to use for
1261-
displaying the password reset form. Defaults to
1262-
:file:`registration/password_reset_form.html` if not supplied.
1293+
.. attribute:: template_name
12631294

1264-
* ``form_class``: Form that will be used to get the email of
1265-
the user to reset the password for. Defaults to
1266-
:class:`~django.contrib.auth.forms.PasswordResetForm`.
1295+
The full name of a template to use for displaying the password reset
1296+
form. Defaults to :file:`registration/password_reset_form.html` if not
1297+
supplied.
12671298

1268-
* ``email_template_name``: The full name of a template to use for
1269-
generating the email with the reset password link. Defaults to
1270-
:file:`registration/password_reset_email.html` if not supplied.
1299+
.. attribute:: form_class
12711300

1272-
* ``subject_template_name``: The full name of a template to use for
1273-
the subject of the email with the reset password link. Defaults
1274-
to :file:`registration/password_reset_subject.txt` if not supplied.
1301+
Form that will be used to get the email of the user to reset the
1302+
password for. Defaults to
1303+
:class:`~django.contrib.auth.forms.PasswordResetForm`.
12751304

1276-
* ``token_generator``: Instance of the class to check the one time link.
1277-
This will default to ``default_token_generator``, it's an instance of
1278-
``django.contrib.auth.tokens.PasswordResetTokenGenerator``.
1305+
.. attribute:: email_template_name
12791306

1280-
* ``success_url``: The URL to redirect to after a successful password reset
1281-
request. Defaults to ``'password_reset_done'``.
1307+
The full name of a template to use for generating the email with the
1308+
reset password link. Defaults to
1309+
:file:`registration/password_reset_email.html` if not supplied.
12821310

1283-
* ``from_email``: A valid email address. By default Django uses
1284-
the :setting:`DEFAULT_FROM_EMAIL`.
1311+
.. attribute:: subject_template_name
12851312

1286-
* ``extra_context``: A dictionary of context data that will be added to the
1287-
default context data passed to the template.
1313+
The full name of a template to use for the subject of the email with
1314+
the reset password link. Defaults to
1315+
:file:`registration/password_reset_subject.txt` if not supplied.
12881316

1289-
* ``html_email_template_name``: The full name of a template to use
1290-
for generating a :mimetype:`text/html` multipart email with the password
1291-
reset link. By default, HTML email is not sent.
1317+
.. attribute:: token_generator
12921318

1293-
* ``extra_email_context``: A dictionary of context data that will be
1294-
available in the email template. It can be used to override default
1295-
template context values listed below e.g. ``domain``.
1319+
Instance of the class to check the one time link. This will default to
1320+
``default_token_generator``, it's an instance of
1321+
``django.contrib.auth.tokens.PasswordResetTokenGenerator``.
1322+
1323+
.. attribute:: success_url
1324+
1325+
The URL to redirect to after a successful password reset request.
1326+
Defaults to ``'password_reset_done'``.
1327+
1328+
.. attribute:: from_email
1329+
1330+
A valid email address. By default Django uses the
1331+
:setting:`DEFAULT_FROM_EMAIL`.
1332+
1333+
.. attribute:: extra_context
1334+
1335+
A dictionary of context data that will be added to the default context
1336+
data passed to the template.
1337+
1338+
.. attribute:: html_email_template_name
1339+
1340+
The full name of a template to use for generating a
1341+
:mimetype:`text/html` multipart email with the password reset link. By
1342+
default, HTML email is not sent.
1343+
1344+
.. attribute:: extra_email_context
1345+
1346+
A dictionary of context data that will be available in the email
1347+
template. It can be used to override default template context values
1348+
listed below e.g. ``domain``.
12961349

12971350
**Template context:**
12981351

@@ -1348,12 +1401,15 @@ implementation details see :ref:`using-the-views`.
13481401

13491402
**Attributes:**
13501403

1351-
* ``template_name``: The full name of a template to use.
1352-
Defaults to :file:`registration/password_reset_done.html` if not
1353-
supplied.
1404+
.. attribute:: template_name
1405+
1406+
The full name of a template to use. Defaults to
1407+
:file:`registration/password_reset_done.html` if not supplied.
13541408

1355-
* ``extra_context``: A dictionary of context data that will be added to the
1356-
default context data passed to the template.
1409+
.. attribute:: extra_context
1410+
1411+
A dictionary of context data that will be added to the default context
1412+
data passed to the template.
13571413

13581414
.. class:: PasswordResetConfirmView
13591415

@@ -1369,34 +1425,48 @@ implementation details see :ref:`using-the-views`.
13691425

13701426
**Attributes:**
13711427

1372-
* ``template_name``: The full name of a template to display the confirm
1373-
password view. Default value is
1374-
:file:`registration/password_reset_confirm.html`.
1428+
.. attribute:: template_name
1429+
1430+
The full name of a template to display the confirm password view.
1431+
Default value is :file:`registration/password_reset_confirm.html`.
1432+
1433+
.. attribute:: token_generator
1434+
1435+
Instance of the class to check the password. This will default to
1436+
``default_token_generator``, it's an instance of
1437+
``django.contrib.auth.tokens.PasswordResetTokenGenerator``.
1438+
1439+
.. attribute:: post_reset_login
1440+
1441+
A boolean indicating if the user should be automatically authenticated
1442+
after a successful password reset. Defaults to ``False``.
13751443

1376-
* ``token_generator``: Instance of the class to check the password. This
1377-
will default to ``default_token_generator``, it's an instance of
1378-
``django.contrib.auth.tokens.PasswordResetTokenGenerator``.
1444+
.. attribute:: post_reset_login_backend
13791445

1380-
* ``post_reset_login``: A boolean indicating if the user should be
1381-
automatically authenticated after a successful password reset. Defaults
1382-
to ``False``.
1446+
A dotted path to the authentication backend to use when authenticating
1447+
a user if ``post_reset_login`` is ``True``. Required only if you have
1448+
multiple :setting:`AUTHENTICATION_BACKENDS` configured. Defaults to
1449+
``None``.
13831450

1384-
* ``post_reset_login_backend``: A dotted path to the authentication
1385-
backend to use when authenticating a user if ``post_reset_login`` is
1386-
``True``. Required only if you have multiple
1387-
:setting:`AUTHENTICATION_BACKENDS` configured. Defaults to ``None``.
1451+
.. attribute:: form_class
13881452

1389-
* ``form_class``: Form that will be used to set the password. Defaults to
1390-
:class:`~django.contrib.auth.forms.SetPasswordForm`.
1453+
Form that will be used to set the password. Defaults to
1454+
:class:`~django.contrib.auth.forms.SetPasswordForm`.
13911455

1392-
* ``success_url``: URL to redirect after the password reset done. Defaults
1393-
to ``'password_reset_complete'``.
1456+
.. attribute:: success_url
13941457

1395-
* ``extra_context``: A dictionary of context data that will be added to the
1396-
default context data passed to the template.
1458+
URL to redirect after the password reset done. Defaults to
1459+
``'password_reset_complete'``.
13971460

1398-
* ``reset_url_token``: Token parameter displayed as a component of password
1399-
reset URLs. Defaults to ``'set-password'``.
1461+
.. attribute:: extra_context
1462+
1463+
A dictionary of context data that will be added to the default context
1464+
data passed to the template.
1465+
1466+
.. attribute:: reset_url_token
1467+
1468+
Token parameter displayed as a component of password reset URLs.
1469+
Defaults to ``'set-password'``.
14001470

14011471
**Template context:**
14021472

@@ -1415,11 +1485,15 @@ implementation details see :ref:`using-the-views`.
14151485

14161486
**Attributes:**
14171487

1418-
* ``template_name``: The full name of a template to display the view.
1419-
Defaults to :file:`registration/password_reset_complete.html`.
1488+
.. attribute:: template_name
1489+
1490+
The full name of a template to display the view. Defaults to
1491+
:file:`registration/password_reset_complete.html`.
1492+
1493+
.. attribute:: extra_context
14201494

1421-
* ``extra_context``: A dictionary of context data that will be added to the
1422-
default context data passed to the template.
1495+
A dictionary of context data that will be added to the default context
1496+
data passed to the template.
14231497

14241498
Helper functions
14251499
----------------

0 commit comments

Comments
 (0)