【发布时间】:2023-04-06 07:14:01
【问题描述】:
我正在尝试获取从 HTML 表单接收的 GET 数据。
但它给了我 MultiValueDictError。 这也是说
During handling of the above exception, another exception occurred:
我的 HTML 代码:
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
<form action="home_redirect/fd" id="redirect" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<input type="text" value={{user}} name="user">
<input type="submit">
</form>
<script>
document.getElementById("redirect").submit()
</script>
</body>
</html>
我的views.py:
def home(request):
user = request.POST['user']
return render(request, 'main.html', {'login': user})
【问题讨论】:
-
method="post",所以数据在request.POST(请求的有效载荷)中。
标签: javascript html python-3.x django django-views