开发者

Django: Make all formset forms required?

Exactly like this question, except that one got closed and accepted without a real answer. It looks like I can use a custom formset and override the clean method, but that still doe开发者_运维百科sn't answer how I check that they're all filled in. What properties am I supposed to be looking at?

The formset is smart enough to ignore extra forms that were not changed.

*Screams* This has caused me nothing but agony.


Think I found the solution by digging through the source...

class BaseVehicleFormSet(BaseFormSet):
    def clean(self):
        for i in range(self.total_form_count()):
            if not self.forms[i].has_changed():
                raise ValidationError("All vehicle forms must be filled in. Press \"remove\" if you've added too many.")
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜