summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/auth/default.txt60
1 files changed, 30 insertions, 30 deletions
diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt
index 24d044156c..7b89061a07 100644
--- a/docs/topics/auth/default.txt
+++ b/docs/topics/auth/default.txt
@@ -1105,12 +1105,12 @@ patterns.
* ``template_name``: The full name of a template to display the view.
Defaults to :file:`registration/password_reset_complete.html`.
- * ``current_app``: A hint indicating which application contains the current
- view. See the :ref:`namespaced URL resolution strategy
- <topics-http-reversing-url-namespaces>` for more information.
+ * ``current_app``: A hint indicating which application contains the current
+ view. See the :ref:`namespaced URL resolution strategy
+ <topics-http-reversing-url-namespaces>` for more information.
- * ``extra_context``: A dictionary of context data that will be added to the
- default context data passed to the template.
+ * ``extra_context``: A dictionary of context data that will be added to the
+ default context data passed to the template.
Helper functions
----------------
@@ -1170,37 +1170,37 @@ provides several built-in forms located in :mod:`django.contrib.auth.forms`:
.. method:: confirm_login_allowed(user)
- .. versionadded:: 1.7
+ .. versionadded:: 1.7
- By default, ``AuthenticationForm`` rejects users whose ``is_active`` flag
- is set to ``False``. You may override this behavior with a custom policy to
- determine which users can log in. Do this with a custom form that subclasses
- ``AuthenticationForm`` and overrides the ``confirm_login_allowed`` method.
- This method should raise a :exc:`~django.core.exceptions.ValidationError`
- if the given user may not log in.
+ By default, ``AuthenticationForm`` rejects users whose ``is_active`` flag
+ is set to ``False``. You may override this behavior with a custom policy to
+ determine which users can log in. Do this with a custom form that subclasses
+ ``AuthenticationForm`` and overrides the ``confirm_login_allowed`` method.
+ This method should raise a :exc:`~django.core.exceptions.ValidationError`
+ if the given user may not log in.
- For example, to allow all users to log in, regardless of "active" status::
+ For example, to allow all users to log in, regardless of "active" status::
- from django.contrib.auth.forms import AuthenticationForm
+ from django.contrib.auth.forms import AuthenticationForm
- class AuthenticationFormWithInactiveUsersOkay(AuthenticationForm):
- def confirm_login_allowed(self, user):
- pass
+ class AuthenticationFormWithInactiveUsersOkay(AuthenticationForm):
+ def confirm_login_allowed(self, user):
+ pass
- Or to allow only some active users to log in::
+ Or to allow only some active users to log in::
- class PickyAuthenticationForm(AuthenticationForm):
- def confirm_login_allowed(self, user):
- if not user.is_active:
- raise forms.ValidationError(
- _("This account is inactive."),
- code='inactive',
- )
- if user.username.startswith('b'):
- raise forms.ValidationError(
- _("Sorry, accounts starting with 'b' aren't welcome here."),
- code='no_b_users',
- )
+ class PickyAuthenticationForm(AuthenticationForm):
+ def confirm_login_allowed(self, user):
+ if not user.is_active:
+ raise forms.ValidationError(
+ _("This account is inactive."),
+ code='inactive',
+ )
+ if user.username.startswith('b'):
+ raise forms.ValidationError(
+ _("Sorry, accounts starting with 'b' aren't welcome here."),
+ code='no_b_users',
+ )
.. class:: PasswordChangeForm