Reputation: 809
On my website, the user can type into this form and hit submit:
<form action="{% url "reikna" pk=doc.id %}" method="post">
{% csrf_token %}
calc_date <input type="text" id="calc_date" />
<input type="submit" value="Submit" />
</form>
Parts of the view function reikna()
:
def reikna(request):
calc_date = request.POST.get("calc_date", False)
f = open('calc_log.txt', 'w')
f.write(str(calc_date)+'\n')
The calc_log.txt file always contains False
, even though I type something into the form. What am I doing incorrectly? As I understand it, the id
attribute should be the identifier for the request.post.get()
function.
Upvotes: 0
Views: 272
Reputation: 52028
calc_date <input type="text" id="calc_date" />
should be calc_date <input type="text" name="calc_date" />
Upvotes: 2