@@ -998,39 +998,50 @@ implementation details see :ref:`using-the-views`.
998
998
999
999
**Attributes:**
1000
1000
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
1003
1002
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 `.
1006
1005
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`.
1010
1015
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
1013
1017
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.
1017
1020
1018
- .. warning::
1021
+ .. attribute:: redirect_authenticated_user
1019
1022
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``.
1026
1026
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::
1030
1028
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`.
1034
1045
1035
1046
Here's what ``LoginView`` does:
1036
1047
@@ -1137,22 +1148,33 @@ implementation details see :ref:`using-the-views`.
1137
1148
1138
1149
**Attributes:**
1139
1150
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
1142
1152
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 `.
1145
1155
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`.
1149
1160
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
1152
1169
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`.
1156
1178
1157
1179
**Template context:**
1158
1180
@@ -1189,20 +1211,28 @@ implementation details see :ref:`using-the-views`.
1189
1211
1190
1212
**Attributes:**
1191
1213
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.
1195
1219
1196
- * ``success_url``: The URL to redirect to after a successful password
1197
- change. Defaults to ``'password_change_done'``.
1220
+ .. attribute:: success_url
1198
1221
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'``.
1203
1224
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.
1206
1236
1207
1237
**Template context:**
1208
1238
@@ -1216,12 +1246,15 @@ implementation details see :ref:`using-the-views`.
1216
1246
1217
1247
**Attributes:**
1218
1248
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
1222
1255
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.
1225
1258
1226
1259
.. class:: PasswordResetView
1227
1260
@@ -1257,42 +1290,62 @@ implementation details see :ref:`using-the-views`.
1257
1290
1258
1291
**Attributes:**
1259
1292
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
1263
1294
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 .
1267
1298
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
1271
1300
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` .
1275
1304
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
1279
1306
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.
1282
1310
1283
- * ``from_email``: A valid email address. By default Django uses
1284
- the :setting:`DEFAULT_FROM_EMAIL`.
1311
+ .. attribute:: subject_template_name
1285
1312
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.
1288
1316
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
1292
1318
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``.
1296
1349
1297
1350
**Template context:**
1298
1351
@@ -1348,12 +1401,15 @@ implementation details see :ref:`using-the-views`.
1348
1401
1349
1402
**Attributes:**
1350
1403
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.
1354
1408
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.
1357
1413
1358
1414
.. class:: PasswordResetConfirmView
1359
1415
@@ -1369,34 +1425,48 @@ implementation details see :ref:`using-the-views`.
1369
1425
1370
1426
**Attributes:**
1371
1427
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``.
1375
1443
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
1379
1445
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``.
1383
1450
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
1388
1452
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`.
1391
1455
1392
- * ``success_url``: URL to redirect after the password reset done. Defaults
1393
- to ``'password_reset_complete'``.
1456
+ .. attribute:: success_url
1394
1457
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'`` .
1397
1460
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'``.
1400
1470
1401
1471
**Template context:**
1402
1472
@@ -1415,11 +1485,15 @@ implementation details see :ref:`using-the-views`.
1415
1485
1416
1486
**Attributes:**
1417
1487
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
1420
1494
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.
1423
1497
1424
1498
Helper functions
1425
1499
----------------
0 commit comments