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
4c35a173
Kaydet (Commit)
4c35a173
authored
May 25, 2018
tarafından
Srinivas Reddy Thatiparthy
Kaydeden (comit)
Tim Graham
May 25, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29423 -- Documented Field.value_from_object().
üst
738a0a4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
custom-model-fields.txt
docs/howto/custom-model-fields.txt
+2
-2
fields.txt
docs/ref/models/fields.txt
+6
-0
No files found.
docs/howto/custom-model-fields.txt
Dosyayı görüntüle @
4c35a173
...
@@ -679,8 +679,8 @@ Converting field data for serialization
...
@@ -679,8 +679,8 @@ Converting field data for serialization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To customize how the values are serialized by a serializer, you can override
To customize how the values are serialized by a serializer, you can override
:meth:`~Field.value_to_string`. Using
``value_from_object()`` is the best way
:meth:`~Field.value_to_string`. Using
:meth:`~Field.value_from_object` is the
to get the field's value prior to serialization. For example, since our
best way to get the field's value prior to serialization. For example, since
``HandField`` uses strings for its data storage anyway, we can reuse some
``HandField`` uses strings for its data storage anyway, we can reuse some
existing conversion code::
existing conversion code::
...
...
docs/ref/models/fields.txt
Dosyayı görüntüle @
4c35a173
...
@@ -1857,6 +1857,12 @@ Field API reference
...
@@ -1857,6 +1857,12 @@ Field API reference
Besides saving to the database, the field also needs to know how to
Besides saving to the database, the field also needs to know how to
serialize its value:
serialize its value:
.. method:: value_from_object(obj)
Returns the field's value for the given model instance.
This method is often used by :meth:`value_to_string`.
.. method:: value_to_string(obj)
.. method:: value_to_string(obj)
Converts ``obj`` to a string. Used to serialize the value of the field.
Converts ``obj`` to a string. Used to serialize the value of the field.
...
...
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