开发者

Django formset - validate one of the forms, not all

I have a formset that generates two forms that have different initial values. When the user submits the form, they're only going to fill out one of them, not both. These initial values get populated in the view, which (I think) means FormSet can't figure out if they've changed or not, so default validation fails. But really, all I care abo开发者_JAVA百科ut is if one of them is valid. I'd like to take that valid form and process it. What's the best way to go about this?


Not only formset.is_valid() exists, but also

for form in formset.forms:
  if form.is_valid():
    ..

should work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜