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
96317ad8
Kaydet (Commit)
96317ad8
authored
Eyl 01, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #21414 -- Removed Field.related per deprecation timeline.
üst
f1761e3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
25 deletions
+1
-25
related.py
django/db/models/fields/related.py
+1
-10
tests.py
tests/basic/tests.py
+0
-15
No files found.
django/db/models/fields/related.py
Dosyayı görüntüle @
96317ad8
...
...
@@ -12,9 +12,7 @@ from django.db.models.deletion import CASCADE, SET_DEFAULT, SET_NULL
from
django.db.models.query_utils
import
PathInfo
from
django.db.models.utils
import
make_model_tuple
from
django.utils
import
six
from
django.utils.deprecation
import
(
RemovedInDjango20Warning
,
RemovedInDjango110Warning
,
)
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
django.utils.encoding
import
force_text
,
smart_text
from
django.utils.functional
import
cached_property
,
curry
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -358,13 +356,6 @@ class RelatedField(Field):
self
.
verbose_name
=
self
.
remote_field
.
model
.
_meta
.
verbose_name
self
.
remote_field
.
set_field_name
()
@property
def
related
(
self
):
warnings
.
warn
(
"Usage of field.related has been deprecated. Use field.remote_field instead."
,
RemovedInDjango110Warning
,
2
)
return
self
.
remote_field
def
do_related_class
(
self
,
other
,
cls
):
self
.
set_attributes_from_rel
()
self
.
contribute_to_related_class
(
other
,
self
.
remote_field
)
...
...
tests/basic/tests.py
Dosyayı görüntüle @
96317ad8
from
__future__
import
unicode_literals
import
threading
import
warnings
from
datetime
import
datetime
,
timedelta
from
django.core.exceptions
import
MultipleObjectsReturned
,
ObjectDoesNotExist
from
django.db
import
DEFAULT_DB_ALIAS
,
DatabaseError
,
connections
from
django.db.models.fields
import
Field
from
django.db.models.fields.related
import
ForeignObjectRel
from
django.db.models.manager
import
BaseManager
from
django.db.models.query
import
EmptyQuerySet
,
QuerySet
from
django.test
import
(
...
...
@@ -771,16 +769,3 @@ class ModelRefreshTests(TestCase):
a
=
Article
.
objects
.
create
(
pub_date
=
self
.
_truncate_ms
(
datetime
.
now
()))
with
self
.
assertNumQueries
(
0
):
a
.
refresh_from_db
(
fields
=
[])
class
TestRelatedObjectDeprecation
(
SimpleTestCase
):
def
test_field_related_deprecation
(
self
):
field
=
SelfRef
.
_meta
.
get_field
(
'selfref'
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
warns
:
warnings
.
simplefilter
(
'always'
)
self
.
assertIsInstance
(
field
.
related
,
ForeignObjectRel
)
self
.
assertEqual
(
len
(
warns
),
1
)
self
.
assertEqual
(
str
(
warns
.
pop
()
.
message
),
'Usage of field.related has been deprecated. Use field.remote_field instead.'
)
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