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
80855a4b
Kaydet (Commit)
80855a4b
authored
Eki 21, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #21894 -- Corrected a form.clean() example in case a superclass doesn't return data.
üst
12aeed8c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
validation.txt
docs/ref/forms/validation.txt
+18
-10
No files found.
docs/ref/forms/validation.txt
Dosyayı görüntüle @
80855a4b
...
...
@@ -371,16 +371,24 @@ example::
In this code, if the validation error is raised, the form will display an
error message at the top of the form (normally) describing the problem.
Note that the call to ``super(ContactForm, self).clean()`` in the example code
ensures that any validation logic in parent classes is maintained.
The second approach might involve assigning the error message to one of the
fields. In this case, let's assign an error message to both the "subject" and
"cc_myself" rows in the form display. Be careful when doing this in practice,
since it can lead to confusing form output. We're showing what is possible
here and leaving it up to you and your designers to work out what works
effectively in your particular situation. Our new code (replacing the previous
sample) looks like this::
The call to ``super(ContactForm, self).clean()`` in the example code ensures
that any validation logic in parent classes is maintained. If your form
inherits another that doesn't return a ``cleaned_data`` dictionary in its
``clean()`` method (doing so is optional), then don't assign ``cleaned_data``
to the result of the ``super()`` call and use ``self.cleaned_data`` instead::
def clean(self):
super(ContactForm, self).clean()
cc_myself = self.cleaned_data.get("cc_myself")
...
The second approach for reporting validation errors might involve assigning the
error message to one of the fields. In this case, let's assign an error message
to both the "subject" and "cc_myself" rows in the form display. Be careful when
doing this in practice, since it can lead to confusing form output. We're
showing what is possible here and leaving it up to you and your designers to
work out what works effectively in your particular situation. Our new code
(replacing the previous sample) looks like this::
from django import forms
...
...
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