当我在 django2 中添加功能时遇到问题无法添加新帖子并且这段代码
/notes/add NOT NULL 约束处出现 IntegrityError 失败: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 )
繁星淼淼
相关分类