开发者

How to see if form has any data in it Django

开发者 https://www.devze.com 2023-03-14 15:45 出处:网络
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?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消