尝试将 JavaScript 中的表单数据发送到我的 Django Url 时,ROM Djanjo 出现错误 500

问题描述 投票:0回答:1
javascript python-3.x django forms django-forms
1个回答
0
投票

如果您的

IntegrityError
是 None 类型,似乎会出现问题
enteredValue
。确保您发送的值有效。

此外,像这样修改你的

edit
视图来处理这种情况

enteredValue = request.POST.get('edited_task')
get_task = get_object_or_404(Task, pk=pk)

if enteredValue is not None:
    get_task.task = enteredValue
    get_task.save()

return redirect('home')

这样,您只会在提供非 NULL 值时更新任务,这将避免

not NULL CONSTRAINT
错误。

© www.soinside.com 2019 - 2024. All rights reserved.