Django Form不会保存到DB

时间:2015-02-26 10:19:29

标签: django modelform

我有一个Django Form对象,我提交并尝试保存 - 但由于某种原因它不会写入DB。

instance = Probation.objects.get(id=formid)
if request.method == 'POST':
    form = ProbationForm(request.POST, instance=instance)
    if form.is_valid():
        tt = form.cleaned_data # all my data is in here
        #I usually put form.save() here - but not working. Doing it manually
        aa = Probation.objects.get(id=formid)
        aa.outline = "hello"
        aa.save()
        # The DB is not updated
        But if i print out the value of aa.outline it is "hello"
        bb = Probation.objects.get(id=formid)
        rr = bb.outline
        # if i print out rr its "hello"

数据库没有反映这一点。我的下一行是断言 - 所以没有其他事情发生。

0 个答案:

没有答案