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
ef889d5b
Kaydet (Commit)
ef889d5b
authored
Ara 14, 2016
tarafından
Morgan Aubert
Kaydeden (comit)
Tim Graham
Ara 14, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27599 -- Fixed Field.__str__() crash for fields not attached to models.
üst
3be22689
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
__init__.py
django/db/models/fields/__init__.py
+6
-1
tests.py
tests/model_fields/tests.py
+3
-2
No files found.
django/db/models/fields/__init__.py
Dosyayı görüntüle @
ef889d5b
...
...
@@ -186,7 +186,12 @@ class Field(RegisterLookupMixin):
self
.
error_messages
=
messages
def
__str__
(
self
):
""" Return "app_label.model_label.field_name". """
"""
Return "app_label.model_label.field_name" for fields attached to
models.
"""
if
not
hasattr
(
self
,
'model'
):
return
super
(
Field
,
self
)
.
__str__
()
model
=
self
.
model
app
=
model
.
_meta
.
app_label
return
'
%
s.
%
s.
%
s'
%
(
app
,
model
.
_meta
.
object_name
,
self
.
name
)
...
...
tests/model_fields/tests.py
Dosyayı görüntüle @
ef889d5b
from
django
import
forms
from
django.db
import
models
from
django.test
import
SimpleTestCase
,
TestCase
from
django.utils.encoding
import
force_str
from
.models
import
(
Foo
,
RenamedField
,
VerboseNameField
,
Whiz
,
WhizIter
,
WhizIterEmpty
,
...
...
@@ -56,8 +55,10 @@ class BasicFieldTests(TestCase):
self
.
assertIsInstance
(
field
.
formfield
(
choices_form_class
=
klass
),
klass
)
def
test_field_str
(
self
):
f
=
models
.
Field
()
self
.
assertEqual
(
str
(
f
),
'<django.db.models.fields.Field>'
)
f
=
Foo
.
_meta
.
get_field
(
'a'
)
self
.
assertEqual
(
force_
str
(
f
),
'model_fields.Foo.a'
)
self
.
assertEqual
(
str
(
f
),
'model_fields.Foo.a'
)
def
test_field_ordering
(
self
):
"""Fields are ordered based on their creation."""
...
...
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