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
ad491ecc
Kaydet (Commit)
ad491ecc
authored
Eyl 17, 2014
tarafından
Damien Baty
Kaydeden (comit)
Tim Graham
Eyl 18, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23488 -- Added AnonymousUser.get_username().
üst
8facb02f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
0 deletions
+17
-0
models.py
django/contrib/auth/models.py
+3
-0
test_basic.py
django/contrib/auth/tests/test_basic.py
+5
-0
auth.txt
docs/ref/contrib/auth.txt
+9
-0
No files found.
django/contrib/auth/models.py
Dosyayı görüntüle @
ad491ecc
...
...
@@ -509,3 +509,6 @@ class AnonymousUser(object):
def
is_authenticated
(
self
):
return
False
def
get_username
(
self
):
return
self
.
username
django/contrib/auth/tests/test_basic.py
Dosyayı görüntüle @
ad491ecc
...
...
@@ -41,6 +41,9 @@ class BasicTestCase(TestCase):
u
.
set_password
(
None
)
self
.
assertFalse
(
u
.
has_usable_password
())
# Check username getter
self
.
assertEqual
(
u
.
get_username
(),
'testuser'
)
# Check authentication/permissions
self
.
assertTrue
(
u
.
is_authenticated
())
self
.
assertFalse
(
u
.
is_staff
)
...
...
@@ -66,6 +69,8 @@ class BasicTestCase(TestCase):
"Check the properties of the anonymous user"
a
=
AnonymousUser
()
self
.
assertEqual
(
a
.
pk
,
None
)
self
.
assertEqual
(
a
.
username
,
''
)
self
.
assertEqual
(
a
.
get_username
(),
''
)
self
.
assertFalse
(
a
.
is_authenticated
())
self
.
assertFalse
(
a
.
is_staff
)
self
.
assertFalse
(
a
.
is_active
)
...
...
docs/ref/contrib/auth.txt
Dosyayı görüntüle @
ad491ecc
...
...
@@ -269,6 +269,10 @@ Anonymous users
these differences:
* :ref:`id <automatic-primary-key-fields>` is always ``None``.
* :attr:`~django.contrib.auth.models.User.username` is always the empty
string.
* :meth:`~django.contrib.auth.models.User.get_username()` always returns
the empty string.
* :attr:`~django.contrib.auth.models.User.is_staff` and
:attr:`~django.contrib.auth.models.User.is_superuser` are always
``False``.
...
...
@@ -285,6 +289,11 @@ Anonymous users
:meth:`~django.db.models.Model.save` and
:meth:`~django.db.models.Model.delete()` raise :exc:`NotImplementedError`.
.. versionadded:: 1.8
``AnonymousUser.get_username()`` has been added to
better mirror :class:`django.contrib.auth.models.User`.
In practice, you probably won't need to use
:class:`~django.contrib.auth.models.AnonymousUser` objects on your own, but
they're used by Web requests, as explained in the next section.
...
...
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