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
1a49b894
Kaydet (Commit)
1a49b894
authored
Nis 08, 2017
tarafından
Collin Anderson
Kaydeden (comit)
Tim Graham
Haz 09, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27953 -- Added instance's pk to Model.__str__().
üst
7c9cb1ed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
7 deletions
+13
-7
base.py
django/db/models/base.py
+1
-1
tutorial02.txt
docs/intro/tutorial02.txt
+4
-4
2.0.txt
docs/releases/2.0.txt
+3
-0
tests.py
tests/str/tests.py
+5
-2
No files found.
django/db/models/base.py
Dosyayı görüntüle @
1a49b894
...
@@ -505,7 +505,7 @@ class Model(metaclass=ModelBase):
...
@@ -505,7 +505,7 @@ class Model(metaclass=ModelBase):
return
'<
%
s:
%
s>'
%
(
self
.
__class__
.
__name__
,
u
)
return
'<
%
s:
%
s>'
%
(
self
.
__class__
.
__name__
,
u
)
def
__str__
(
self
):
def
__str__
(
self
):
return
'
%
s object
'
%
self
.
__class__
.
__name__
return
'
%
s object
(
%
s)'
%
(
self
.
__class__
.
__name__
,
self
.
pk
)
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
Model
):
if
not
isinstance
(
other
,
Model
):
...
...
docs/intro/tutorial02.txt
Dosyayı görüntüle @
1a49b894
...
@@ -437,11 +437,11 @@ Once you're in the shell, explore the :doc:`database API </topics/db/queries>`::
...
@@ -437,11 +437,11 @@ Once you're in the shell, explore the :doc:`database API </topics/db/queries>`::
# objects.all() displays all the questions in the database.
# objects.all() displays all the questions in the database.
>>> Question.objects.all()
>>> Question.objects.all()
<QuerySet [<Question: Question object>]>
<QuerySet [<Question: Question object
(1)
>]>
Wait a minute. ``<Question: Question object
>`` is, utterly, an unhelpful representation
Wait a minute. ``<Question: Question object
(1)>`` isn't a helpful
of this object. Let's fix that by editing the ``Question`` model (in the
representation of this object. Let's fix that by editing the ``Question`` model
``polls/models.py`` file) and adding a
(in the
``polls/models.py`` file) and adding a
:meth:`~django.db.models.Model.__str__` method to both ``Question`` and
:meth:`~django.db.models.Model.__str__` method to both ``Question`` and
``Choice``:
``Choice``:
...
...
docs/releases/2.0.txt
Dosyayı görüntüle @
1a49b894
...
@@ -441,6 +441,9 @@ Miscellaneous
...
@@ -441,6 +441,9 @@ Miscellaneous
:class:`~django.views.i18n.JavaScriptCatalog` view now raises ``ValueError``
:class:`~django.views.i18n.JavaScriptCatalog` view now raises ``ValueError``
instead of passing silently.
instead of passing silently.
* A model instance's primary key now appears in the default ``Model.__str__()``
method, e.g. ``Question object (1)``.
.. _deprecated-features-2.0:
.. _deprecated-features-2.0:
Features deprecated in 2.0
Features deprecated in 2.0
...
...
tests/str/tests.py
Dosyayı görüntüle @
1a49b894
...
@@ -30,5 +30,8 @@ class SimpleTests(TestCase):
...
@@ -30,5 +30,8 @@ class SimpleTests(TestCase):
# coerce the returned value.
# coerce the returned value.
self
.
assertIsInstance
(
obj
.
__str__
(),
str
)
self
.
assertIsInstance
(
obj
.
__str__
(),
str
)
self
.
assertIsInstance
(
obj
.
__repr__
(),
str
)
self
.
assertIsInstance
(
obj
.
__repr__
(),
str
)
self
.
assertEqual
(
str
(
obj
),
'Default object'
)
self
.
assertEqual
(
str
(
obj
),
'Default object (None)'
)
self
.
assertEqual
(
repr
(
obj
),
'<Default: Default object>'
)
self
.
assertEqual
(
repr
(
obj
),
'<Default: Default object (None)>'
)
obj2
=
Default
(
pk
=
100
)
self
.
assertEqual
(
str
(
obj2
),
'Default object (100)'
)
self
.
assertEqual
(
repr
(
obj2
),
'<Default: Default object (100)>'
)
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