简体   繁体   中英

request.post.get() is empty — Django

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.

calc_date <input type="text" id="calc_date" />应该是calc_date <input type="text" name="calc_date" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM