可以将循环数据插入django模型吗?..
这是我的代码。在view.py
class EmpCreateView(CreateView): fields = () model = models.Employee def form_valid(self, form): self.object = form.save(commit=False) loopdo = 5 while loopdo > 0: self.object.name = "work?" self.object.no = loopdo self.object.save() loopdo -= 1 return super(ModelFormMixin, self).form_valid(form)
它只插入1个数据。
答案 0 :(得分:1)