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
48c17807
Kaydet (Commit)
48c17807
authored
Ara 21, 2018
tarafından
Gregory N. Schmit
Kaydeden (comit)
Tim Graham
Şub 08, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #16027 -- Added app_label to ContentType.__str__().
üst
5cc6f02f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
13 deletions
+25
-13
index.html
django/contrib/admin/templates/admin/index.html
+1
-1
models.py
django/contrib/auth/models.py
+1
-5
models.py
django/contrib/contenttypes/models.py
+8
-1
3.0.txt
docs/releases/3.0.txt
+2
-1
test_models.py
tests/contenttypes_tests/test_models.py
+9
-1
tests.py
tests/i18n/contenttypes/tests.py
+2
-2
tests.py
tests/multiple_database/tests.py
+2
-2
No files found.
django/contrib/admin/templates/admin/index.html
Dosyayı görüntüle @
48c17807
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
{% endif %}
{% endif %}
<br>
<br>
{% if entry.content_type %}
{% if entry.content_type %}
<span
class=
"mini quiet"
>
{% filter capfirst %}{{ entry.content_type }}{% endfilter %}
</span>
<span
class=
"mini quiet"
>
{% filter capfirst %}{{ entry.content_type
.name
}}{% endfilter %}
</span>
{% else %}
{% else %}
<span
class=
"mini quiet"
>
{% trans 'Unknown content' %}
</span>
<span
class=
"mini quiet"
>
{% trans 'Unknown content' %}
</span>
{% endif %}
{% endif %}
...
...
django/contrib/auth/models.py
Dosyayı görüntüle @
48c17807
...
@@ -71,11 +71,7 @@ class Permission(models.Model):
...
@@ -71,11 +71,7 @@ class Permission(models.Model):
'codename'
)
'codename'
)
def
__str__
(
self
):
def
__str__
(
self
):
return
"
%
s |
%
s |
%
s"
%
(
return
'
%
s |
%
s'
%
(
self
.
content_type
,
self
.
name
)
self
.
content_type
.
app_label
,
self
.
content_type
,
self
.
name
,
)
def
natural_key
(
self
):
def
natural_key
(
self
):
return
(
self
.
codename
,)
+
self
.
content_type
.
natural_key
()
return
(
self
.
codename
,)
+
self
.
content_type
.
natural_key
()
...
...
django/contrib/contenttypes/models.py
Dosyayı görüntüle @
48c17807
...
@@ -142,7 +142,7 @@ class ContentType(models.Model):
...
@@ -142,7 +142,7 @@ class ContentType(models.Model):
unique_together
=
((
'app_label'
,
'model'
),)
unique_together
=
((
'app_label'
,
'model'
),)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
app_labeled_
name
@property
@property
def
name
(
self
):
def
name
(
self
):
...
@@ -151,6 +151,13 @@ class ContentType(models.Model):
...
@@ -151,6 +151,13 @@ class ContentType(models.Model):
return
self
.
model
return
self
.
model
return
str
(
model
.
_meta
.
verbose_name
)
return
str
(
model
.
_meta
.
verbose_name
)
@property
def
app_labeled_name
(
self
):
model
=
self
.
model_class
()
if
not
model
:
return
self
.
model
return
'
%
s |
%
s'
%
(
model
.
_meta
.
app_label
,
model
.
_meta
.
verbose_name
)
def
model_class
(
self
):
def
model_class
(
self
):
"""Return the model class for this type of content."""
"""Return the model class for this type of content."""
try
:
try
:
...
...
docs/releases/3.0.txt
Dosyayı görüntüle @
48c17807
...
@@ -285,7 +285,8 @@ Django 3.0, we're removing these APIs at this time.
...
@@ -285,7 +285,8 @@ Django 3.0, we're removing these APIs at this time.
Miscellaneous
Miscellaneous
-------------
-------------
* ...
* ``ContentType.__str__()`` now includes the model's ``app_label`` to
disambiguate model's with the same name in different apps.
.. _deprecated-features-3.0:
.. _deprecated-features-3.0:
...
...
tests/contenttypes_tests/test_models.py
Dosyayı görüntüle @
48c17807
...
@@ -201,7 +201,15 @@ class ContentTypesTests(TestCase):
...
@@ -201,7 +201,15 @@ class ContentTypesTests(TestCase):
def
test_str
(
self
):
def
test_str
(
self
):
ct
=
ContentType
.
objects
.
get
(
app_label
=
'contenttypes_tests'
,
model
=
'site'
)
ct
=
ContentType
.
objects
.
get
(
app_label
=
'contenttypes_tests'
,
model
=
'site'
)
self
.
assertEqual
(
str
(
ct
),
'site'
)
self
.
assertEqual
(
str
(
ct
),
'contenttypes_tests | site'
)
def
test_app_labeled_name
(
self
):
ct
=
ContentType
.
objects
.
get
(
app_label
=
'contenttypes_tests'
,
model
=
'site'
)
self
.
assertEqual
(
ct
.
app_labeled_name
,
'contenttypes_tests | site'
)
def
test_app_labeled_name_unknown_model
(
self
):
ct
=
ContentType
(
app_label
=
'contenttypes_tests'
,
model
=
'unknown'
)
self
.
assertEqual
(
ct
.
app_labeled_name
,
'unknown'
)
class
TestRouter
:
class
TestRouter
:
...
...
tests/i18n/contenttypes/tests.py
Dosyayı görüntüle @
48c17807
...
@@ -20,6 +20,6 @@ class ContentTypeTests(TestCase):
...
@@ -20,6 +20,6 @@ class ContentTypeTests(TestCase):
def
test_verbose_name
(
self
):
def
test_verbose_name
(
self
):
company_type
=
ContentType
.
objects
.
get
(
app_label
=
'i18n'
,
model
=
'company'
)
company_type
=
ContentType
.
objects
.
get
(
app_label
=
'i18n'
,
model
=
'company'
)
with
translation
.
override
(
'en'
):
with
translation
.
override
(
'en'
):
self
.
assertEqual
(
str
(
company_type
),
'Company'
)
self
.
assertEqual
(
str
(
company_type
),
'
i18n |
Company'
)
with
translation
.
override
(
'fr'
):
with
translation
.
override
(
'fr'
):
self
.
assertEqual
(
str
(
company_type
),
'Société'
)
self
.
assertEqual
(
str
(
company_type
),
'
i18n |
Société'
)
tests/multiple_database/tests.py
Dosyayı görüntüle @
48c17807
...
@@ -840,8 +840,8 @@ class QueryTestCase(TestCase):
...
@@ -840,8 +840,8 @@ class QueryTestCase(TestCase):
# Set a foreign key with an object from a different database
# Set a foreign key with an object from a different database
msg
=
(
msg
=
(
'Cannot assign "<ContentType:
book>": the current database router
'
'Cannot assign "<ContentType:
multiple_database | book>": the
'
'prevents this relation.'
'
current database router
prevents this relation.'
)
)
with
self
.
assertRaisesMessage
(
ValueError
,
msg
):
with
self
.
assertRaisesMessage
(
ValueError
,
msg
):
review1
.
content_object
=
dive
review1
.
content_object
=
dive
...
...
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