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
a40a34a4
Kaydet (Commit)
a40a34a4
authored
Şub 28, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #13015 -- Clarified language about model instances attached to forms.
üst
35885078
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
modelforms.txt
docs/topics/forms/modelforms.txt
+18
-3
No files found.
docs/topics/forms/modelforms.txt
Dosyayı görüntüle @
a40a34a4
...
...
@@ -232,7 +232,7 @@ Overriding the clean() method
You can override the ``clean()`` method on a model form to provide additional
validation in the same way you can on a normal form.
A model form instance
boun
d to a model object will contain an ``instance``
A model form instance
attache
d to a model object will contain an ``instance``
attribute that gives its methods access to that specific model instance.
.. warning::
...
...
@@ -674,6 +674,21 @@ There are a couple of things to note, however.
a default field. To opt-out from default fields, see
:ref:`modelforms-selecting-fields`.
Providing initial values
------------------------
As with regular forms, it's possible to specify initial data for forms by
specifying an ``initial`` parameter when instantiating the form. Initial
values provided this way will override both initial values from the form field
and values from an attached model instance. For example::
>>> article = Article.objects.get(pk1=)
>>> article.headline
'My headline'
>>> form = ArticleForm(initial={'headline': 'Initial headline'), instance=article)
>>> form['pub_date'].value()
'Initial headline'
.. _modelforms-factory:
ModelForm factory function
...
...
@@ -840,8 +855,8 @@ As with regular formsets, it's possible to :ref:`specify initial data
<formsets-initial-data>` for forms in the formset by specifying an ``initial``
parameter when instantiating the model formset class returned by
:func:`~django.forms.models.modelformset_factory`. However, with model
formsets, the initial values only apply to extra forms, those that aren't
bound
to an existing object
instance.
formsets, the initial values only apply to extra forms, those that aren't
attached to an existing model
instance.
.. _saving-objects-in-the-formset:
...
...
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