Answer the question
In order to leave comments, you need to log in
How to get text from POST request?
I'm sorry for such a stupid question
. There is a layout:
...
<form action="" method="POST">
{% csrf_token %}
<input type="text">
<input type="submit" name="city">
</form>
...
def home(request):
print(request.POST)
...
<QueryDict: {'csrfmiddlewaretoken': ['DRd1em12YAXIGFY2Fdp26vfqcrgip5VyOvSWJPGIDOEAaT3vb4AM5eAXcLnzUKSO'], 'city': ['Submit']}>
Answer the question
In order to leave comments, you need to log in
The error was due to two inputs, I changed the layout to this one and it worked:
<form action="" method="POST">
{% csrf_token %}
<input type="text" name="city">
<button type="submit">Submit</button>
</form>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question