Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
09119dff
Kaydet (Commit)
09119dff
authored
Haz 16, 2016
tarafından
Bang Dao + Tam Huynh
Kaydeden (comit)
Tim Graham
Haz 24, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26719 -- Normalized email in AbstractUser.clean().
üst
7e303d15
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
1 deletion
+27
-1
models.py
django/contrib/auth/models.py
+4
-0
1.11.txt
docs/releases/1.11.txt
+5
-0
customizing.txt
docs/topics/auth/customizing.txt
+13
-1
test_models.py
tests/auth_tests/test_models.py
+5
-0
No files found.
django/contrib/auth/models.py
Dosyayı görüntüle @
09119dff
...
...
@@ -344,6 +344,10 @@ class AbstractUser(AbstractBaseUser, PermissionsMixin):
verbose_name_plural
=
_
(
'users'
)
abstract
=
True
def
clean
(
self
):
super
(
AbstractUser
,
self
)
.
clean
()
self
.
email
=
self
.
__class__
.
objects
.
normalize_email
(
self
.
email
)
def
get_full_name
(
self
):
"""
Returns the first_name plus the last_name, with a space in between.
...
...
docs/releases/1.11.txt
Dosyayı görüntüle @
09119dff
...
...
@@ -293,6 +293,11 @@ Miscellaneous
<django.db.models.Model.validate_unique>` no longer checks empty strings for
uniqueness as the database interprets the value as ``NULL``.
* If you subclass :class:`.AbstractUser` and override ``clean()``, be sure it
calls ``super()``. :meth:`.BaseUserManager.normalize_email` is called in a
new :meth:`.AbstractUser.clean` method so that normalization is applied in
cases like model form validation.
.. _deprecated-features-1.11:
Features deprecated in 1.11
...
...
docs/topics/auth/customizing.txt
Dosyayı görüntüle @
09119dff
...
...
@@ -692,6 +692,18 @@ The following attributes and methods are available on any subclass of
Returns an HMAC of the password field. Used for
:ref:`session-invalidation-on-password-change`.
:class:`~models.AbstractUser` subclasses :class:`~models.AbstractBaseUser`:
.. class:: models.AbstractUser
.. method:: clean()
.. versionadded:: 1.11
Normalizes the email by calling
:meth:`.BaseUserManager.normalize_email`. If you override this method,
be sure to call ``super()`` to retain the normalization.
You should also define a custom manager for your ``User`` model. If your
``User`` model defines ``username``, ``email``, ``is_staff``, ``is_active``,
``is_superuser``, ``last_login``, and ``date_joined`` fields the same as
...
...
@@ -759,7 +771,7 @@ Extending Django's default ``User``
If you're entirely happy with Django's :class:`~django.contrib.auth.models.User`
model and you just want to add some additional profile information, you could
simply subclass
``django.contrib.auth.models.AbstractUser`
` and add your
simply subclass
:class:`django.contrib.auth.models.AbstractUser
` and add your
custom profile fields, although we'd recommend a separate model as described in
the "Model design considerations" note of :ref:`specifying-custom-user-model`.
``AbstractUser`` provides the full implementation of the default
...
...
tests/auth_tests/test_models.py
Dosyayı görüntüle @
09119dff
...
...
@@ -194,6 +194,11 @@ class AbstractUserTestCase(TestCase):
user2
=
User
.
objects
.
create_user
(
username
=
'user2'
)
self
.
assertIsNone
(
user2
.
last_login
)
def
test_user_clean_normalize_email
(
self
):
user
=
User
(
username
=
'user'
,
password
=
'foo'
,
email
=
'foo@BAR.com'
)
user
.
clean
()
self
.
assertEqual
(
user
.
email
,
'foo@bar.com'
)
def
test_user_double_save
(
self
):
"""
Calling user.save() twice should trigger password_changed() once.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment