从模板文件 (Django) 获取 POST 后 views.py 文件无输出

No Output from views.py file after getting POST from template file (Django)

我一直在尝试使用 django 获取填写表单的详细信息,返回到 python 文件中。一切似乎都很好,但终端中没有显示表单详细信息。

views.py 文件:

from django.shortcuts import render
from basicapp import forms
# Create your views here. 
def index(request):
return render(request,'basicapp/index.html')

def form_name_view(request):
    form = forms.FormName()
    if request == "POST":
        form = forms.FormName(request.POST)

        if form.is_valid():
            #DO SOMETHING
            print("Validation SUCCESS")
            print("NAME: " + form.cleaned_data['name'])
            print("EMAIL: " + form.cleaned_data['email'])
            print("AVANODA KARUTHTHU: " + form.cleaned_data['text'])


    return render(request,'basicapp/form_page.html', {'form' : form } )

form_page.html 文件:(我删除了 Bootstrap CDN)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Forms</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, shrink-to-fit=no">                                                                                  
    
</head>
<body>
    <div class="container">
        <div class = "jumbotron">
            <h2> Fill out the form </h2>
            <form method="POST" action = "">
                {{ form.as_p }}
                {% csrf_token %}
                <input type="submit" class = "btn btn-primary" value = "Submit">
            </form>
        </div>
    </div>
</body>
</html>

请帮忙。提前致谢。

更新:找到解决方案。请参考附图。

更正:

if request.method == "POST":index 函数下