| 457 | Other built-in views |
| 458 | -------------------- |
| 459 | |
| 460 | In addition to the `login` view, the authentication system includes a |
| 461 | few other useful built-in views: |
| 462 | |
| 463 | ``django.contrib.auth.views.logout`` |
| 464 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 465 | |
| 466 | **Description:** |
| 467 | |
| 468 | Logs a user out. |
| 469 | |
| 470 | **Optional arguments:** |
| 471 | |
| 472 | * ``template_name``: The full name of a template to display after |
| 473 | logging the user out. This will default to |
| 474 | ``registration/logged_out.html`` if no argument is supplied. |
| 475 | |
| 476 | **Template context:** |
| 477 | |
| 478 | * ``title``: The string "Logged out", localized. |
| 479 | |
| 480 | ``django.contrib.auth.views.logout_then_login`` |
| 481 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 482 | |
| 483 | **Description:** |
| 484 | |
| 485 | Logs a user out, then redirects to the login page. |
| 486 | |
| 487 | **Optional arguments:** |
| 488 | |
| 489 | * ``login_url``: The URL of the login page to redirect to. This |
| 490 | will default to ``/accounts/login/`` if not supplied. |
| 491 | |
| 492 | ``django.contrib.auth.views.password_change`` |
| 493 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 494 | |
| 495 | **Description:** |
| 496 | |
| 497 | Allows a user to change their password. |
| 498 | |
| 499 | **Optional arguments:** |
| 500 | |
| 501 | * ``template_name``: The full name of a template to use for |
| 502 | displaying the password change form. This will default to |
| 503 | ``registration/password_change_form.html`` if not supplied. |
| 504 | |
| 505 | **Template context:** |
| 506 | |
| 507 | * ``form``: The password change form. |
| 508 | |
| 509 | ``django.contrib.auth.views.password_change_done`` |
| 510 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 511 | |
| 512 | **Description:** |
| 513 | |
| 514 | The page shown after a user has changed their password. |
| 515 | |
| 516 | **Optional arguments:** |
| 517 | |
| 518 | * ``template_name``: The full name of a template to use. This will |
| 519 | default to ``registration/password_change_done.html`` if not |
| 520 | supplied. |
| 521 | |
| 522 | ``django.contrib.auth.views.password_reset`` |
| 523 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 524 | |
| 525 | **Description:** |
| 526 | |
| 527 | Allows a user to reset their password, and sends them the new password |
| 528 | in an email. |
| 529 | |
| 530 | **Optional arguments:** |
| 531 | |
| 532 | * ``template_name``: The full name of a template to use for |
| 533 | displaying the password reset form. This will default to |
| 534 | ``registration/password_reset_form.html`` if not supplied. |
| 535 | |
| 536 | * ``email_template_name``: The full name of a template to use for |
| 537 | generating the email with the new password. This will default to |
| 538 | ``registration/password_reset_email.html`` if not supplied. |
| 539 | |
| 540 | **Template context:** |
| 541 | |
| 542 | * ``form``: The form for resetting the user's password. |
| 543 | |
| 544 | ``django.contrib.auth.views.password_reset_done`` |
| 545 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 546 | |
| 547 | **Description:** |
| 548 | |
| 549 | The page shown after a user has reset their password. |
| 550 | |
| 551 | **Optional arguments:** |
| 552 | |
| 553 | * ``template_name``: The full name of a template to use. This will |
| 554 | default to ``registration/password_reset_done.html`` if not |
| 555 | supplied. |
| 556 | |
| 557 | ``django.contrib.auth.views.redirect_to_login`` |
| 558 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 559 | |
| 560 | **Description:** |
| 561 | |
| 562 | Redirects to the login page, and then back to another URL after a |
| 563 | successful login. |
| 564 | |
| 565 | **Required arguments:** |
| 566 | |
| 567 | * ``next``: The URL to redirect to after a successful login. |
| 568 | |
| 569 | **Optional arguments:** |
| 570 | |
| 571 | * ``login_url``: The URL of the login page to redirect to. This |
| 572 | will default to ``/accounts/login/`` if not supplied. |
| 573 | |
| 574 | Built-in manipulators |
| 575 | --------------------- |
| 576 | |
| 577 | If you don't want to use the built-in views, but want the convenience |
| 578 | of not having to write manipulators for this functionality, the |
| 579 | authentication system provides several built-in manipulators: |
| 580 | |
| 581 | * ``django.contrib.auth.forms.AdminPasswordChangeForm``: A |
| 582 | manipulator used in the admin interface to change a user's |
| 583 | password. |
| 584 | |
| 585 | * ``django.contrib.auth.forms.AuthenticationForm``: A manipulator |
| 586 | for logging a user in. |
| 587 | |
| 588 | * ``django.contrib.auth.forms.PasswordChangeForm``: A manipulator |
| 589 | for allowing a user to change their password. |
| 590 | |
| 591 | * ``django.contrib.auth.forms.PasswordResetForm``: A manipulator |
| 592 | for resetting a user's password and emailing the new password to |
| 593 | them. |
| 594 | |
| 595 | * ``django.contrib.auth.forms.UserCreationForm``: A manipulator |
| 596 | for creating a new user. |
| 597 | |