1👍
You need to return self.cleaned_data
from both the base and the subclass methods.
1👍
I believe returning the self.cleaned_data to the base class only should work.
class MyForm(forms.Form):
field = forms.CharField()
def clean(self):
"do stuff"
return self.cleaned_data
class MyEmailingForm(MyForm):
def clean(self):
super(MyEmailingForm, self).clean()
send_mail('Form data',
self.cleaned_data['field'],
'Form <noreply@myform.co.uk>',
["formdata@myform.co.uk"],
fail_silently=True)
return self.cleaned_data
- [Answered ]-Django 1.7: allow_empty_file not working in ImageField
- [Answered ]-Django-admin: cant access admin backend "attempt to write a readonly database"
- [Answered ]-Handling whitespaces in django tooltips while using translations
- [Answered ]-Django Crispy forms doesn't save when custom layout is added
0👍
You have to use the is_valid()
method first.
- [Answered ]-Why does timezone aware datetime have 2 times in django
- [Answered ]-Django JWT asking for username/password
0👍
Actually the field self.cleaned_data['field']
you are setting in base is not included in cleaned_data
.
try
class MyForm(forms.Form):
field = forms.CharField()
def clean(self):
cd = self.cleaned_data
"do stuff with cd"
return cd
- [Answered ]-DjangoRestFramework – How do I customize the frontend?
- [Answered ]-Django query – how to get latest row during distinct
Source:stackexchange.com