How to see if form has any data in it Django
If i have a form say 开发者_如何学编程recipe
and in it a charfield that can be left blank say serves
how do i check to see in my view if the user has left the field blank or not?
Thanks,
...
form = MyForm(request.POST)
if form.is_valid():
if form.cleaned_data['serves'] == "":
...
https://docs.djangoproject.com/en/dev/ref/forms/api/#django.forms.Form.cleaned_data
精彩评论