[Fixed]-How to pass the values from the template as an argument to the function in views?

1👍

According to your comments above this should work:

<form method="post">{% csrf_token %}
    Ratings: <input type="number" name="rate" step="0.1" min="1" max="5"><br>
    <input type="submit" value="Submit" name="mybtn">
</form>

Then in your views.py:

def request_page(request):
    users_id = request.user.id + 671
    if request.method == 'POST':
        updater.rate_movie(672, 6251, float(request.POST['rate']))
    return render(request, 'path/to/template.html')
👤nik_m

Leave a comment