Django formsets: make first required?

前端 未结 4 477
独厮守ぢ
独厮守ぢ 2020-11-28 04:05

These formsets are exhibiting exactly the opposite behavior that I want.

My view is set up like this:

def post(request): # TODO: handle vehi         


        
4条回答
  •  隐瞒了意图╮
    2020-11-28 04:54

    New in Django 1.7: you can specify this behaviour with your formset_factory

    https://docs.djangoproject.com/en/1.8/topics/forms/formsets/#validate-min

    VehicleFormSetFactory = formset_factory(VehicleForm, min_num=1, validate_min=True, extra=1)
    

提交回复
热议问题