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
Is that typo... It should be request.POST
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With