【发布时间】:2020-08-01 21:15:16
【问题描述】:
当我在 django2 中添加函数时遇到问题,无法添加新帖子而这段代码
/notes/add 处的完整性错误 NOT NULL 约束失败:notes_note.created
这些观点
def note_add(request):
# form = NoteForm()
if request.method == 'POST':
form = NoteForm(request.POST)
if form.is_valid():
new_form = form.save(commit=False)
new_form.user = request.user
new_form.save()
return redirect('/notes')
else:
form = NoteForm()
context={
"form":form,
}
return render(request, 'add.html', context )
【问题讨论】:
-
IntegrityError at /notes/add NOT NULL 约束失败:notes_note.created
-
idownvotedbecau.se/imageofcode 没有dv,但请复制问题中的代码,请勿发布代码图像。
-
@memeal:可以分享一下模型吗?
标签: python html css django web