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 pa...
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 me...
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 ...
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 ch...
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 s...
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...
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 po...
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_pa...
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), return...
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 c...
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_validat...
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 fi...
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 provi...
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, so...
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 ‘sen...
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.contri...
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 log...
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 authentic...
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 GE...
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 ...
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 ...
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 dictiona...
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 ...
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 ina...
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 ...
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 s...
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