Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'WSGIRequest' object has no attribute 'Post' [closed]

I am new to django and python and I am trying to update the database boolean field from checkboxes in the html page. when I try to access the checkboxes in the views method, this error occurs: 'WSGIRequest' object has no attribute 'Post'

This is my code in the HTML:

<body>

    {% if all_crosses %}

    <form action= 'lines/inventory/' method="POST">
    {%csrf_token%}
    <input type="submit" value="Submit" />

    {% for cross in all_crosses %}
        
        <table style="margin-bottom: 20px">

        <!-- Checkbox + Name -->
        <tr>

            <td>
                {% if cross.exists %}
                <input type="checkbox" value="{{ cross.id }}" name="exist" id="exist{{ forloop.counter }}" checked >
                {% else %}
                <input type="checkbox" value="{{ cross.id }}" name="exist" id="exist{{ forloop.counter }}"  >
                {% endif %}
          </td>
          
          <td>
                <li>Cross Name: {{cross.Name}}</li>
          </td>
       </tr>
      </table>
      {% endfor %}
     </form>
  {% endif %}
  </body>

This is the code in the views:

def update_existence(request):

   all_crosses = RaisingStatus.objects.all()

   if request.method == "POST":
       if ('exist' in request.POST):
           print('Post')  
           checks = request.Post['exist']
           # My desired processing here

   return render(request, 'lines/inventory.html', {'all_crosses' : all_crosses})

I also tried request.Post.getlist() and gave the same error

like image 687
نوار مكيس Avatar asked Nov 23 '15 10:11

نوار مكيس


1 Answers

Is that typo... It should be request.POST

like image 163
Raja Simon Avatar answered Oct 13 '22 22:10

Raja Simon