[Fixed]-Inserting multiple instances of the form into DB in Django

1👍

What about doing this:

def test_view(request, list):

   my_form = MyForm(request.POST) 

   for x in list:
        my_instance = my_form.save(commit = false)
        if my_instance.id:
                my_instance.id = None
        my_instance.variable_field = x['content']
        my_form.save()

Leave a comment