doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
email Optional (blank=True). Email address.
django.ref.contrib.auth#django.contrib.auth.models.User.email
email_user(subject, message, from_email=None, **kwargs) Sends an email to the user. If from_email is None, Django uses the DEFAULT_FROM_EMAIL. Any **kwargs are passed to the underlying send_mail() call.
django.ref.contrib.auth#django.contrib.auth.models.User.email_user
first_name Optional (blank=True). 150 characters or fewer.
django.ref.contrib.auth#django.contrib.auth.models.User.first_name
get_all_permissions(obj=None) Returns a set of permission strings that the user has, both through group and user permissions. If obj is passed in, only returns the permissions for this specific object.
django.ref.contrib.auth#django.contrib.auth.models.User.get_all_permissions
get_full_name() Returns the first_name plus the last_name, with a space in between.
django.ref.contrib.auth#django.contrib.auth.models.User.get_full_name
get_group_permissions(obj=None) Returns a set of permission strings that the user has, through their groups. If obj is passed in, only returns the group permissions for this specific object.
django.ref.contrib.auth#django.contrib.auth.models.User.get_group_permissions
get_short_name() Returns the first_name.
django.ref.contrib.auth#django.contrib.auth.models.User.get_short_name
get_user_permissions(obj=None) Returns a set of permission strings that the user has directly. If obj is passed in, only returns the user permissions for this specific object.
django.ref.contrib.auth#django.contrib.auth.models.User.get_user_permissions
get_username() Returns the username for the user. Since the User model can be swapped out, you should use this method instead of referencing the username attribute directly.
django.ref.contrib.auth#django.contrib.auth.models.User.get_username
groups Many-to-many relationship to Group
django.ref.contrib.auth#django.contrib.auth.models.User.groups
has_module_perms(package_name) Returns True if the user has any permissions in the given package (the Django app label). If the user is inactive, this method will always return False. For an active superuser, this method will always return True.
django.ref.contrib.auth#django.contrib.auth.models.User.has_module_perms
has_perm(perm, obj=None) Returns True if the user has the specified permission, where perm is in the format "<app label>.<permission codename>". (see documentation on permissions). If the user is inactive, this method will always return False. For an active superuser, this method will always return True. If obj is passed in, this method won’t check for a permission for the model, but for this specific object.
django.ref.contrib.auth#django.contrib.auth.models.User.has_perm
has_perms(perm_list, obj=None) Returns True if the user has each of the specified permissions, where each perm is in the format "<app label>.<permission codename>". If the user is inactive, this method will always return False. For an active superuser, this method will always return True. If obj is passed in, this method won’t check for permissions for the model, but for the specific object.
django.ref.contrib.auth#django.contrib.auth.models.User.has_perms
has_usable_password() Returns False if set_unusable_password() has been called for this user.
django.ref.contrib.auth#django.contrib.auth.models.User.has_usable_password
is_active Boolean. Designates whether this user account should be considered active. We recommend that you set this flag to False instead of deleting accounts; that way, if your applications have any foreign keys to users, the foreign keys won’t break. This doesn’t necessarily control whether or not the user can log in. Authentication backends aren’t required to check for the is_active flag but the default backend (ModelBackend) and the RemoteUserBackend do. You can use AllowAllUsersModelBackend or AllowAllUsersRemoteUserBackend if you want to allow inactive users to login. In this case, you’ll also want to customize the AuthenticationForm used by the LoginView as it rejects inactive users. Be aware that the permission-checking methods such as has_perm() and the authentication in the Django admin all return False for inactive users.
django.ref.contrib.auth#django.contrib.auth.models.User.is_active
is_anonymous Read-only attribute which is always False. This is a way of differentiating User and AnonymousUser objects. Generally, you should prefer using is_authenticated to this attribute.
django.ref.contrib.auth#django.contrib.auth.models.User.is_anonymous
is_authenticated Read-only attribute which is always True (as opposed to AnonymousUser.is_authenticated which is always False). This is a way to tell if the user has been authenticated. This does not imply any permissions and doesn’t check if the user is active or has a valid session. Even though normally you will check this attribute on request.user to find out whether it has been populated by the AuthenticationMiddleware (representing the currently logged-in user), you should know this attribute is True for any User instance.
django.ref.contrib.auth#django.contrib.auth.models.User.is_authenticated
is_staff Boolean. Designates whether this user can access the admin site.
django.ref.contrib.auth#django.contrib.auth.models.User.is_staff
is_superuser Boolean. Designates that this user has all permissions without explicitly assigning them.
django.ref.contrib.auth#django.contrib.auth.models.User.is_superuser
last_login A datetime of the user’s last login.
django.ref.contrib.auth#django.contrib.auth.models.User.last_login
last_name Optional (blank=True). 150 characters or fewer.
django.ref.contrib.auth#django.contrib.auth.models.User.last_name
password Required. A hash of, and metadata about, the password. (Django doesn’t store the raw password.) Raw passwords can be arbitrarily long and can contain any character. See the password documentation.
django.ref.contrib.auth#django.contrib.auth.models.User.password
set_password(raw_password) Sets the user’s password to the given raw string, taking care of the password hashing. Doesn’t save the User object. When the raw_password is None, the password will be set to an unusable password, as if set_unusable_password() were used.
django.ref.contrib.auth#django.contrib.auth.models.User.set_password
set_unusable_password() Marks the user as having no password set. This isn’t the same as having a blank string for a password. check_password() for this user will never return True. Doesn’t save the User object. You may need this if authentication for your application takes place against an existing external source such as an LDAP directory.
django.ref.contrib.auth#django.contrib.auth.models.User.set_unusable_password
user_permissions Many-to-many relationship to Permission
django.ref.contrib.auth#django.contrib.auth.models.User.user_permissions
username Required. 150 characters or fewer. Usernames may contain alphanumeric, _, @, +, . and - characters. The max_length should be sufficient for many use cases. If you need a longer length, please use a custom user model. If you use MySQL with the utf8mb4 encoding (recommended for proper Unicode support), specify at most max_length=191 because MySQL can only create unique indexes with 191 characters in that case by default.
django.ref.contrib.auth#django.contrib.auth.models.User.username
class models.UserManager The User model has a custom manager that has the following helper methods (in addition to the methods provided by BaseUserManager): create_user(username, email=None, password=None, **extra_fields) Creates, saves and returns a User. The username and password are set as given. The domain portion of email is automatically converted to lowercase, and the returned User object will have is_active set to True. If no password is provided, set_unusable_password() will be called. The extra_fields keyword arguments are passed through to the User’s __init__ method to allow setting arbitrary fields on a custom user model. See Creating users for example usage. create_superuser(username, email=None, password=None, **extra_fields) Same as create_user(), but sets is_staff and is_superuser to True. with_perm(perm, is_active=True, include_superusers=True, backend=None, obj=None) Returns users that have the given permission perm either in the "<app label>.<permission codename>" format or as a Permission instance. Returns an empty queryset if no users who have the perm found. If is_active is True (default), returns only active users, or if False, returns only inactive users. Use None to return all users irrespective of active state. If include_superusers is True (default), the result will include superusers. If backend is passed in and it’s defined in AUTHENTICATION_BACKENDS, then this method will use it. Otherwise, it will use the backend in AUTHENTICATION_BACKENDS, if there is only one, or raise an exception.
django.ref.contrib.auth#django.contrib.auth.models.UserManager
create_superuser(username, email=None, password=None, **extra_fields) Same as create_user(), but sets is_staff and is_superuser to True.
django.ref.contrib.auth#django.contrib.auth.models.UserManager.create_superuser
create_user(username, email=None, password=None, **extra_fields) Creates, saves and returns a User. The username and password are set as given. The domain portion of email is automatically converted to lowercase, and the returned User object will have is_active set to True. If no password is provided, set_unusable_password() will be called. The extra_fields keyword arguments are passed through to the User’s __init__ method to allow setting arbitrary fields on a custom user model. See Creating users for example usage.
django.ref.contrib.auth#django.contrib.auth.models.UserManager.create_user
with_perm(perm, is_active=True, include_superusers=True, backend=None, obj=None) Returns users that have the given permission perm either in the "<app label>.<permission codename>" format or as a Permission instance. Returns an empty queryset if no users who have the perm found. If is_active is True (default), returns only active users, or if False, returns only inactive users. Use None to return all users irrespective of active state. If include_superusers is True (default), the result will include superusers. If backend is passed in and it’s defined in AUTHENTICATION_BACKENDS, then this method will use it. Otherwise, it will use the backend in AUTHENTICATION_BACKENDS, if there is only one, or raise an exception.
django.ref.contrib.auth#django.contrib.auth.models.UserManager.with_perm
class CommonPasswordValidator(password_list_path=DEFAULT_PASSWORD_LIST_PATH) Validates whether the password is not a common password. This converts the password to lowercase (to do a case-insensitive comparison) and checks it against a list of 20,000 common password created by Royce Williams. The password_list_path can be set to the path of a custom file of common passwords. This file should contain one lowercase password per line and may be plain text or gzipped.
django.topics.auth.passwords#django.contrib.auth.password_validation.CommonPasswordValidator
get_password_validators(validator_config) Returns a set of validator objects based on the validator_config parameter. By default, all functions use the validators defined in AUTH_PASSWORD_VALIDATORS, but by calling this function with an alternate set of validators and then passing the result into the password_validators parameter of the other functions, your custom set of validators will be used instead. This is useful when you have a typical set of validators to use for most scenarios, but also have a special situation that requires a custom set. If you always use the same set of validators, there is no need to use this function, as the configuration from AUTH_PASSWORD_VALIDATORS is used by default. The structure of validator_config is identical to the structure of AUTH_PASSWORD_VALIDATORS. The return value of this function can be passed into the password_validators parameter of the functions listed above.
django.topics.auth.passwords#django.contrib.auth.password_validation.get_password_validators
class MinimumLengthValidator(min_length=8) Validates whether the password meets a minimum length. The minimum length can be customized with the min_length parameter.
django.topics.auth.passwords#django.contrib.auth.password_validation.MinimumLengthValidator
class NumericPasswordValidator Validates whether the password is not entirely numeric.
django.topics.auth.passwords#django.contrib.auth.password_validation.NumericPasswordValidator
password_changed(password, user=None, password_validators=None) Informs all validators that the password has been changed. This can be used by validators such as one that prevents password reuse. This should be called once the password has been successfully changed. For subclasses of AbstractBaseUser, the password field will be marked as “dirty” when calling set_password() which triggers a call to password_changed() after the user is saved.
django.topics.auth.passwords#django.contrib.auth.password_validation.password_changed
password_validators_help_text_html(password_validators=None) Returns an HTML string with all help texts in an <ul>. This is helpful when adding password validation to forms, as you can pass the output directly to the help_text parameter of a form field.
django.topics.auth.passwords#django.contrib.auth.password_validation.password_validators_help_text_html
password_validators_help_texts(password_validators=None) Returns a list of the help texts of all validators. These explain the password requirements to the user.
django.topics.auth.passwords#django.contrib.auth.password_validation.password_validators_help_texts
class UserAttributeSimilarityValidator(user_attributes=DEFAULT_USER_ATTRIBUTES, max_similarity=0.7) Validates whether the password is sufficiently different from certain attributes of the user. The user_attributes parameter should be an iterable of names of user attributes to compare to. If this argument is not provided, the default is used: 'username', 'first_name', 'last_name', 'email'. Attributes that don’t exist are ignored. The minimum similarity of a rejected password can be set on a scale of 0 to 1 with the max_similarity parameter. A setting of 0 rejects all passwords, whereas a setting of 1 rejects only passwords that are identical to an attribute’s value.
django.topics.auth.passwords#django.contrib.auth.password_validation.UserAttributeSimilarityValidator
validate_password(password, user=None, password_validators=None) Validates a password. If all validators find the password valid, returns None. If one or more validators reject the password, raises a ValidationError with all the error messages from the validators. The user object is optional: if it’s not provided, some validators may not be able to perform any validation and will accept any password.
django.topics.auth.passwords#django.contrib.auth.password_validation.validate_password
user_logged_in() Sent when a user logs in successfully. Arguments sent with this signal: sender The class of the user that just logged in. request The current HttpRequest instance. user The user instance that just logged in.
django.ref.contrib.auth#django.contrib.auth.signals.user_logged_in
user_logged_out() Sent when the logout method is called. sender As above: the class of the user that just logged out or None if the user was not authenticated. request The current HttpRequest instance. user The user instance that just logged out or None if the user was not authenticated.
django.ref.contrib.auth#django.contrib.auth.signals.user_logged_out
user_login_failed() Sent when the user failed to login successfully sender The name of the module used for authentication. credentials A dictionary of keyword arguments containing the user credentials that were passed to authenticate() or your own custom authentication backend. Credentials matching a set of ‘sensitive’ patterns, (including password) will not be sent in the clear as part of the signal. request The HttpRequest object, if one was provided to authenticate().
django.ref.contrib.auth#django.contrib.auth.signals.user_login_failed
update_session_auth_hash(request, user) This function takes the current request and the updated user object from which the new session hash will be derived and updates the session hash appropriately. It also rotates the session key so that a stolen session cookie will be invalidated. Example usage: from django.contrib.auth import update_session_auth_hash def password_change(request): if request.method == 'POST': form = PasswordChangeForm(user=request.user, data=request.POST) if form.is_valid(): form.save() update_session_auth_hash(request, form.user) else: ...
django.topics.auth.default#django.contrib.auth.update_session_auth_hash
class validators.ASCIIUsernameValidator A field validator allowing only ASCII letters and numbers, in addition to @, ., +, -, and _.
django.ref.contrib.auth#django.contrib.auth.validators.ASCIIUsernameValidator
class validators.UnicodeUsernameValidator A field validator allowing Unicode characters, in addition to @, ., +, -, and _. The default validator for User.username.
django.ref.contrib.auth#django.contrib.auth.validators.UnicodeUsernameValidator
class LoginView URL name: login See the URL documentation for details on using named URL patterns. Methods and Attributes template_name The name of a template to display for the view used to log the user in. Defaults to registration/login.html. next_page New in Django 4.0. The URL to redirect to after login. Defaults to LOGIN_REDIRECT_URL. redirect_field_name The name of a GET field containing the URL to redirect to after login. Defaults to next. Overrides the get_default_redirect_url() URL if the given GET parameter is passed. authentication_form A callable (typically a form class) to use for authentication. Defaults to AuthenticationForm. extra_context A dictionary of context data that will be added to the default context data passed to the template. redirect_authenticated_user A boolean that controls whether or not authenticated users accessing the login page will be redirected as if they had just successfully logged in. Defaults to False. Warning If you enable redirect_authenticated_user, other websites will be able to determine if their visitors are authenticated on your site by requesting redirect URLs to image files on your website. To avoid this “social media fingerprinting” information leakage, host all images and your favicon on a separate domain. Enabling redirect_authenticated_user can also result in a redirect loop when using the permission_required() decorator unless the raise_exception parameter is used. success_url_allowed_hosts A set of hosts, in addition to request.get_host(), that are safe for redirecting after login. Defaults to an empty set. get_default_redirect_url() New in Django 4.0. Returns the URL to redirect to after login. The default implementation resolves and returns next_page if set, or LOGIN_REDIRECT_URL otherwise. Here’s what LoginView does: If called via GET, it displays a login form that POSTs to the same URL. More on this in a bit. If called via POST with user submitted credentials, it tries to log the user in. If login is successful, the view redirects to the URL specified in next. If next isn’t provided, it redirects to settings.LOGIN_REDIRECT_URL (which defaults to /accounts/profile/). If login isn’t successful, it redisplays the login form. It’s your responsibility to provide the html for the login template , called registration/login.html by default. This template gets passed four template context variables: form: A Form object representing the AuthenticationForm. next: The URL to redirect to after successful login. This may contain a query string, too. site: The current Site, according to the SITE_ID setting. If you don’t have the site framework installed, this will be set to an instance of RequestSite, which derives the site name and domain from the current HttpRequest. site_name: An alias for site.name. If you don’t have the site framework installed, this will be set to the value of request.META['SERVER_NAME']. For more on sites, see The “sites” framework. If you’d prefer not to call the template registration/login.html, you can pass the template_name parameter via the extra arguments to the as_view method in your URLconf. For example, this URLconf line would use myapp/login.html instead: path('accounts/login/', auth_views.LoginView.as_view(template_name='myapp/login.html')), You can also specify the name of the GET field which contains the URL to redirect to after login using redirect_field_name. By default, the field is called next. Here’s a sample registration/login.html template you can use as a starting point. It assumes you have a base.html template that defines a content block: {% extends "base.html" %} {% block content %} {% if form.errors %} <p>Your username and password didn't match. Please try again.</p> {% endif %} {% if next %} {% if user.is_authenticated %} <p>Your account doesn't have access to this page. To proceed, please login with an account that has access.</p> {% else %} <p>Please login to see this page.</p> {% endif %} {% endif %} <form method="post" action="{% url 'login' %}"> {% csrf_token %} <table> <tr> <td>{{ form.username.label_tag }}</td> <td>{{ form.username }}</td> </tr> <tr> <td>{{ form.password.label_tag }}</td> <td>{{ form.password }}</td> </tr> </table> <input type="submit" value="login"> <input type="hidden" name="next" value="{{ next }}"> </form> {# Assumes you set up the password_reset view in your URLconf #} <p><a href="{% url 'password_reset' %}">Lost password?</a></p> {% endblock %} If you have customized authentication (see Customizing Authentication) you can use a custom authentication form by setting the authentication_form attribute. This form must accept a request keyword argument in its __init__() method and provide a get_user() method which returns the authenticated user object (this method is only ever called after successful form validation).
django.topics.auth.default#django.contrib.auth.views.LoginView
authentication_form A callable (typically a form class) to use for authentication. Defaults to AuthenticationForm.
django.topics.auth.default#django.contrib.auth.views.LoginView.authentication_form
extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.LoginView.extra_context
get_default_redirect_url() New in Django 4.0. Returns the URL to redirect to after login. The default implementation resolves and returns next_page if set, or LOGIN_REDIRECT_URL otherwise.
django.topics.auth.default#django.contrib.auth.views.LoginView.get_default_redirect_url
next_page New in Django 4.0. The URL to redirect to after login. Defaults to LOGIN_REDIRECT_URL.
django.topics.auth.default#django.contrib.auth.views.LoginView.next_page
redirect_authenticated_user A boolean that controls whether or not authenticated users accessing the login page will be redirected as if they had just successfully logged in. Defaults to False. Warning If you enable redirect_authenticated_user, other websites will be able to determine if their visitors are authenticated on your site by requesting redirect URLs to image files on your website. To avoid this “social media fingerprinting” information leakage, host all images and your favicon on a separate domain. Enabling redirect_authenticated_user can also result in a redirect loop when using the permission_required() decorator unless the raise_exception parameter is used.
django.topics.auth.default#django.contrib.auth.views.LoginView.redirect_authenticated_user
redirect_field_name The name of a GET field containing the URL to redirect to after login. Defaults to next. Overrides the get_default_redirect_url() URL if the given GET parameter is passed.
django.topics.auth.default#django.contrib.auth.views.LoginView.redirect_field_name
success_url_allowed_hosts A set of hosts, in addition to request.get_host(), that are safe for redirecting after login. Defaults to an empty set.
django.topics.auth.default#django.contrib.auth.views.LoginView.success_url_allowed_hosts
template_name The name of a template to display for the view used to log the user in. Defaults to registration/login.html.
django.topics.auth.default#django.contrib.auth.views.LoginView.template_name
logout_then_login(request, login_url=None) Logs a user out, then redirects to the login page. URL name: No default URL provided Optional arguments: login_url: The URL of the login page to redirect to. Defaults to settings.LOGIN_URL if not supplied.
django.topics.auth.default#django.contrib.auth.views.logout_then_login
class LogoutView Logs a user out. URL name: logout Attributes: next_page The URL to redirect to after logout. Defaults to LOGOUT_REDIRECT_URL. template_name The full name of a template to display after logging the user out. Defaults to registration/logged_out.html. redirect_field_name The name of a GET field containing the URL to redirect to after log out. Defaults to 'next'. Overrides the next_page URL if the given GET parameter is passed. extra_context A dictionary of context data that will be added to the default context data passed to the template. success_url_allowed_hosts A set of hosts, in addition to request.get_host(), that are safe for redirecting after logout. Defaults to an empty set. Template context: title: The string “Logged out”, localized. site: The current Site, according to the SITE_ID setting. If you don’t have the site framework installed, this will be set to an instance of RequestSite, which derives the site name and domain from the current HttpRequest. site_name: An alias for site.name. If you don’t have the site framework installed, this will be set to the value of request.META['SERVER_NAME']. For more on sites, see The “sites” framework.
django.topics.auth.default#django.contrib.auth.views.LogoutView
extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.LogoutView.extra_context
next_page The URL to redirect to after logout. Defaults to LOGOUT_REDIRECT_URL.
django.topics.auth.default#django.contrib.auth.views.LogoutView.next_page
redirect_field_name The name of a GET field containing the URL to redirect to after log out. Defaults to 'next'. Overrides the next_page URL if the given GET parameter is passed.
django.topics.auth.default#django.contrib.auth.views.LogoutView.redirect_field_name
success_url_allowed_hosts A set of hosts, in addition to request.get_host(), that are safe for redirecting after logout. Defaults to an empty set.
django.topics.auth.default#django.contrib.auth.views.LogoutView.success_url_allowed_hosts
template_name The full name of a template to display after logging the user out. Defaults to registration/logged_out.html.
django.topics.auth.default#django.contrib.auth.views.LogoutView.template_name
class PasswordChangeDoneView URL name: password_change_done The page shown after a user has changed their password. Attributes: template_name The full name of a template to use. Defaults to registration/password_change_done.html if not supplied. extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.PasswordChangeDoneView
extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.PasswordChangeDoneView.extra_context
template_name The full name of a template to use. Defaults to registration/password_change_done.html if not supplied.
django.topics.auth.default#django.contrib.auth.views.PasswordChangeDoneView.template_name
class PasswordChangeView URL name: password_change Allows a user to change their password. Attributes: success_url The URL to redirect to after a successful password change. Defaults to 'password_change_done'. form_class A custom “change password” form which must accept a user keyword argument. The form is responsible for actually changing the user’s password. Defaults to PasswordChangeForm. extra_context A dictionary of context data that will be added to the default context data passed to the template. Template context: form: The password change form (see form_class above).
django.topics.auth.default#django.contrib.auth.views.PasswordChangeView
extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.PasswordChangeView.extra_context
form_class A custom “change password” form which must accept a user keyword argument. The form is responsible for actually changing the user’s password. Defaults to PasswordChangeForm.
django.topics.auth.default#django.contrib.auth.views.PasswordChangeView.form_class
success_url The URL to redirect to after a successful password change. Defaults to 'password_change_done'.
django.topics.auth.default#django.contrib.auth.views.PasswordChangeView.success_url
class PasswordResetCompleteView URL name: password_reset_complete Presents a view which informs the user that the password has been successfully changed. Attributes: template_name The full name of a template to display the view. Defaults to registration/password_reset_complete.html. extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.PasswordResetCompleteView
extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.PasswordResetCompleteView.extra_context
template_name The full name of a template to display the view. Defaults to registration/password_reset_complete.html.
django.topics.auth.default#django.contrib.auth.views.PasswordResetCompleteView.template_name
class PasswordResetConfirmView URL name: password_reset_confirm Presents a form for entering a new password. Keyword arguments from the URL: uidb64: The user’s id encoded in base 64. token: Token to check that the password is valid. Attributes: template_name The full name of a template to display the confirm password view. Default value is 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. post_reset_login A boolean indicating if the user should be automatically authenticated after a successful password reset. Defaults to False. post_reset_login_backend A dotted path to the authentication backend to use when authenticating a user if post_reset_login is True. Required only if you have multiple AUTHENTICATION_BACKENDS configured. Defaults to None. form_class Form that will be used to set the password. Defaults to SetPasswordForm. success_url URL to redirect after the password reset done. Defaults to 'password_reset_complete'. extra_context A dictionary of context data that will be added to the default context data passed to the template. reset_url_token Token parameter displayed as a component of password reset URLs. Defaults to 'set-password'. Template context: form: The form (see form_class above) for setting the new user’s password. validlink: Boolean, True if the link (combination of uidb64 and token) is valid or unused yet.
django.topics.auth.default#django.contrib.auth.views.PasswordResetConfirmView
extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.PasswordResetConfirmView.extra_context
form_class Form that will be used to set the password. Defaults to SetPasswordForm.
django.topics.auth.default#django.contrib.auth.views.PasswordResetConfirmView.form_class
post_reset_login A boolean indicating if the user should be automatically authenticated after a successful password reset. Defaults to False.
django.topics.auth.default#django.contrib.auth.views.PasswordResetConfirmView.post_reset_login
post_reset_login_backend A dotted path to the authentication backend to use when authenticating a user if post_reset_login is True. Required only if you have multiple AUTHENTICATION_BACKENDS configured. Defaults to None.
django.topics.auth.default#django.contrib.auth.views.PasswordResetConfirmView.post_reset_login_backend
reset_url_token Token parameter displayed as a component of password reset URLs. Defaults to 'set-password'.
django.topics.auth.default#django.contrib.auth.views.PasswordResetConfirmView.reset_url_token
success_url URL to redirect after the password reset done. Defaults to 'password_reset_complete'.
django.topics.auth.default#django.contrib.auth.views.PasswordResetConfirmView.success_url
template_name The full name of a template to display the confirm password view. Default value is registration/password_reset_confirm.html.
django.topics.auth.default#django.contrib.auth.views.PasswordResetConfirmView.template_name
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.
django.topics.auth.default#django.contrib.auth.views.PasswordResetConfirmView.token_generator
class PasswordResetDoneView URL name: password_reset_done The page shown after a user has been emailed a link to reset their password. This view is called by default if the PasswordResetView doesn’t have an explicit success_url URL set. Note If the email address provided does not exist in the system, the user is inactive, or has an unusable password, the user will still be redirected to this view but no email will be sent. Attributes: template_name The full name of a template to use. Defaults to registration/password_reset_done.html if not supplied. extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.PasswordResetDoneView
extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.PasswordResetDoneView.extra_context
template_name The full name of a template to use. Defaults to registration/password_reset_done.html if not supplied.
django.topics.auth.default#django.contrib.auth.views.PasswordResetDoneView.template_name
class PasswordResetView URL name: password_reset Allows a user to reset their password by generating a one-time use link that can be used to reset the password, and sending that link to the user’s registered email address. If the email address provided does not exist in the system, this view won’t send an email, but the user won’t receive any error message either. This prevents information leaking to potential attackers. If you want to provide an error message in this case, you can subclass PasswordResetForm and use the form_class attribute. Note Be aware that sending an email costs extra time, hence you may be vulnerable to an email address enumeration timing attack due to a difference between the duration of a reset request for an existing email address and the duration of a reset request for a nonexistent email address. To reduce the overhead, you can use a 3rd party package that allows to send emails asynchronously, e.g. django-mailer. Users flagged with an unusable password (see set_unusable_password() aren’t allowed to request a password reset to prevent misuse when using an external authentication source like LDAP. Note that they won’t receive any error message since this would expose their account’s existence but no mail will be sent either. Attributes: template_name The full name of a template to use for displaying the password reset form. Defaults to registration/password_reset_form.html if not supplied. form_class Form that will be used to get the email of the user to reset the password for. Defaults to PasswordResetForm. email_template_name The full name of a template to use for generating the email with the reset password link. Defaults to registration/password_reset_email.html if not supplied. subject_template_name The full name of a template to use for the subject of the email with the reset password link. Defaults to registration/password_reset_subject.txt if not supplied. token_generator Instance of the class to check the one time link. This will default to default_token_generator, it’s an instance of django.contrib.auth.tokens.PasswordResetTokenGenerator. success_url The URL to redirect to after a successful password reset request. Defaults to 'password_reset_done'. from_email A valid email address. By default Django uses the DEFAULT_FROM_EMAIL. extra_context A dictionary of context data that will be added to the default context data passed to the template. html_email_template_name The full name of a template to use for generating a text/html multipart email with the password reset link. By default, HTML email is not sent. extra_email_context A dictionary of context data that will be available in the email template. It can be used to override default template context values listed below e.g. domain. Template context: form: The form (see form_class above) for resetting the user’s password. Email template context: email: An alias for user.email user: The current User, according to the email form field. Only active users are able to reset their passwords (User.is_active is True). site_name: An alias for site.name. If you don’t have the site framework installed, this will be set to the value of request.META['SERVER_NAME']. For more on sites, see The “sites” framework. domain: An alias for site.domain. If you don’t have the site framework installed, this will be set to the value of request.get_host(). protocol: http or https uid: The user’s primary key encoded in base 64. token: Token to check that the reset link is valid. Sample registration/password_reset_email.html (email body template): Someone asked for password reset for email {{ email }}. Follow the link below: {{ protocol}}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} The same template context is used for subject template. Subject must be single line plain text string.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView
email_template_name The full name of a template to use for generating the email with the reset password link. Defaults to registration/password_reset_email.html if not supplied.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView.email_template_name
extra_context A dictionary of context data that will be added to the default context data passed to the template.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView.extra_context
extra_email_context A dictionary of context data that will be available in the email template. It can be used to override default template context values listed below e.g. domain.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView.extra_email_context
form_class Form that will be used to get the email of the user to reset the password for. Defaults to PasswordResetForm.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView.form_class
from_email A valid email address. By default Django uses the DEFAULT_FROM_EMAIL.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView.from_email
html_email_template_name The full name of a template to use for generating a text/html multipart email with the password reset link. By default, HTML email is not sent.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView.html_email_template_name
subject_template_name The full name of a template to use for the subject of the email with the reset password link. Defaults to registration/password_reset_subject.txt if not supplied.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView.subject_template_name
success_url The URL to redirect to after a successful password reset request. Defaults to 'password_reset_done'.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView.success_url
template_name The full name of a template to use for displaying the password reset form. Defaults to registration/password_reset_form.html if not supplied.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView.template_name
token_generator Instance of the class to check the one time link. This will default to default_token_generator, it’s an instance of django.contrib.auth.tokens.PasswordResetTokenGenerator.
django.topics.auth.default#django.contrib.auth.views.PasswordResetView.token_generator
redirect_to_login(next, login_url=None, redirect_field_name='next') Redirects to the login page, and then back to another URL after a successful login. Required arguments: next: The URL to redirect to after a successful login. Optional arguments: login_url: The URL of the login page to redirect to. Defaults to settings.LOGIN_URL if not supplied. redirect_field_name: The name of a GET field containing the URL to redirect to after log out. Overrides next if the given GET parameter is passed.
django.topics.auth.default#django.contrib.auth.views.redirect_to_login
django.conf.settings.configure(default_settings, **settings)
django.topics.settings#django.conf.settings.configure
handler400
django.ref.urls#django.conf.urls.handler400
handler403
django.ref.urls#django.conf.urls.handler403
handler404
django.ref.urls#django.conf.urls.handler404
handler500
django.ref.urls#django.conf.urls.handler500