开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜