我正在制作定期应用。我需要能够多次保存表单数据。如果我尝试这样做它不起作用:
for a in range(1, 10):
foo.save()
答案 0 :(得分:4)
答案比评论更好:
# foo is your (valid) form
# bar is your object's instance
bar = foo.save(commit=False)
for a in range(1, 10):
bar.save() # save the object
bar.pk = None # reset the pk, next iteration of the loop will save a new one