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
9fd90c40
Kaydet (Commit)
9fd90c40
authored
Mar 11, 2019
tarafından
David Beitey
Kaydeden (comit)
Tim Graham
Mar 12, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Clarified deconstruct() in Custom Model Field docs.
üst
45dfb364
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
custom-model-fields.txt
docs/howto/custom-model-fields.txt
+8
-5
No files found.
docs/howto/custom-model-fields.txt
Dosyayı görüntüle @
9fd90c40
...
...
@@ -231,9 +231,10 @@ Field deconstruction
--------------------
The counterpoint to writing your ``__init__()`` method is writing the
``deconstruct()`` method. This method tells Django how to take an instance
of your new field and reduce it to a serialized form - in particular, what
arguments to pass to ``__init__()`` to re-create it.
:meth:`~.Field.deconstruct` method. It's used during :doc:`model migrations
</topics/migrations>` to tell Django how to take an instance of your new field
and reduce it to a serialized form - in particular, what arguments to pass to
``__init__()`` to re-create it.
If you haven't added any extra options on top of the field you inherited from,
then there's no need to write a new ``deconstruct()`` method. If, however,
...
...
@@ -269,8 +270,10 @@ we can drop it from the keyword arguments for readability::
del kwargs["max_length"]
return name, path, args, kwargs
If you add a new keyword argument, you need to write code to put its value
into ``kwargs`` yourself::
If you add a new keyword argument, you need to write code in ``deconstruct()``
that puts its value into ``kwargs`` yourself. You should also omit the value
from ``kwargs`` when it isn't necessary to reconstruct the state of the field,
such as when the default value is being used::
from django.db import models
...
...
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