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
7767978b
Kaydet (Commit)
7767978b
authored
Haz 03, 2016
tarafından
Baylee Feore
Kaydeden (comit)
Tim Graham
Haz 08, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26702 -- Documented how to change the base class of a custom field.
üst
729b9452
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
custom-model-fields.txt
docs/howto/custom-model-fields.txt
+28
-0
No files found.
docs/howto/custom-model-fields.txt
Dosyayı görüntüle @
7767978b
...
...
@@ -311,6 +311,34 @@ and reconstructing the field::
new_instance = MyField(*args, **kwargs)
self.assertEqual(my_field_instance.some_attribute, new_instance.some_attribute)
Changing a custom field's base class
------------------------------------
You can't change the base class of a custom field because Django won't detect
the change and make a migration for it. For example, if you start with::
class CustomCharField(models.CharField):
...
and then decide that you want to use ``TextField`` instead, you can't change
the subclass like this::
class CustomCharField(models.TextField):
...
Instead, you must create a new custom field class and update your models to
reference it::
class CustomCharField(models.CharField):
...
class CustomTextField(models.TextField):
...
As discussed in :ref:`removing fields <migrations-removing-model-fields>`, you
must retain the original ``CustomCharField`` class as long as you have
migrations that reference it.
Documenting your custom 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