#34323: Django form request is always response with "GET" instead of "POST" even
when I use <form action="" method="post">
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  ODOshmocke                         |
                   Type:  Bug        |         Status:  new
              Component:  Forms      |        Version:  4.1
               Severity:  Normal     |       Keywords:  Forms, request,
           Triage Stage:             |  GET, POST
  Unreviewed                         |      Has patch:  0
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I'm trying to use Django forms but every time I try to do a "POST" Method
 I get a "GET" as the return.

 My HTML:
 `
 <!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <title>Title</title>

     <link rel="stylesheet"
 href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css";
 
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
 crossorigin="anonymous">

     <style>
         input {
             width: 10%;
             margin: 0 auto;
             display: block;
             margin-left: auto;
             margin-right: auto;
         }
     </style>

 </head>

 <body>


     {% load crispy_forms_tags %}

     <div class="container">
         <form action="" method="post">

         {% csrf_token %}
             {% crispy form %}
         <input type="submit" class="btn btn-primary mx-auto d-block">
         </form>
     </div>


 </body>
 </html>
 ´


 My views.py:
 `
 def register(request):


     if request.method == "POST":
         print("Post")
         form = UserInformationForm(request.POST)
         if form.is_valid():
             form.save()
             print(form)
             print("Form is valid")


     else:
         form = UserInformationForm()
         print("Else")


     return render(request, 'index.html', {"form": form})
 ´


 I hope someone can help.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34323>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186334b4052-263b80b4-e707-43e6-bec2-be95c13c75ee-000000%40eu-central-1.amazonses.com.

Reply via email to