current position:Home>[urgent!] Requests in Django Post exception

[urgent!] Requests in Django Post exception

2022-02-03 02:08:53 CSDN Q & A

views.py

def insertcomment(request):    try:        co = comments()        co.com = request.POST['com']# Get input data         co.name = request.POST['name']        co.save()# preservation         print(co.com)    except Exception as e:        print("error:",e)    return redirect("comment")# Redirect to list page 
<input id="name" type="text" name="name" value="{ 
    { request.session.user_name }}" disabled><textarea id="message" name="com" placeholder="Your Message to Us" value="{ 
    { co.com }}" required></textarea>

This is my view function and html Code , Then when I submit the form , My list page doesn't show what I submitted , What is printed out in exception handling is
error: 'name'

I've just started learning django, I don't know what's going on , Can you help me ?




Refer to the answer 1:

Do you use request.method Judge whether the current request method is post request




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030208515317.html

Random recommended