首页 > 解决方案 > Django:“WSGIRequest”对象没有属性“Post”

问题描述

我对 Django 有点陌生,并且已经陷入了一些简单的 POST 问题。

下面是 profile.html 中的 HTML:

<form action="{% url 'profile' %}" method="post">
    {% csrf_token %}
    <input type="text" placeholder="Weight", name="weight">
    <input type="text" placeholder="Reps", name="reps">
    <input type="submit">
</form>

这是相应的视图:

def profile(request):
    if request.method == "GET":
        return render(request, "userprofile/profile.html")

    elif request.method == "POST":
        print(request.Post)
        return render(request, "userprofile/profile.html")

基本上,我现在要做的就是将 POST 数据字典打印到终端中。但是,我收到以下错误:/profile/ 'WSGIRequest' 对象的 AttributeError 没有属性 'Post'。我错过了什么?

非常感谢您的帮助!

标签: pythondjango

解决方案


根据要求没有属性“发布”。但是,有 request.POST

你能request.Post改成request.POST


推荐阅读