Reputation: 21
I want the input entered by user in the template to pass it as arguments to the function which is imported to views.py ..this is the part of that template.
<form action="#" 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>
This is the function I have used to import the function and pass the values as arguments.
def request_page(request):
users_id = request.user.id + 671
if (request.POST.get('mybtn')):
updater.rate_movie(672, 6251, float(request.POST['rate']))
Upvotes: 0
Views: 72
Reputation: 12086
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')
Upvotes: 1