I am sending a POST request to my server from an android application, but I am getting this error:
The POST looks like: http://example/my_page_url/1000 Where the 1000 is an ID.
This is my views method:
def inventory(request, cross_id):
text_file = open("test.txt", "w")
text_file.write('POST Received')
text_file.write(cross_id.__str__())
text_file.close()
return render(request, 'Inventory.html', {})
my template code:
<form action='' method="POST">
<button type="submit" id="btn_save" name="btn_save">Save</button>
{% csrf_token %}
</form>
Actually, I don't really need to call a template, because I want to perform something on the server only. But I am calling the template just to prevent any errors for now.
I have read the other answers for the same problem but all of them have missed the CSRF token in the template or something else in the views method, but I believe the case is different here.