I'm trying to pass date input to django python script in order to retrieve the data based on it.
Here is my code.
view
def daily_usage_report(request):
if request.method == 'POST':
request_date = request.POST.get('request_date')
else:
request_date = date.today()
print(request_date)
...
html
<form method="post" action="#">
<input type="date" name="request_date" id="request_date">
<button class="btn btn-primary"><a href="{% url 'daily_usage_report' %}" style="color: white;">Daily Usage Report</a></button>
</form>
I tried to fill the form with random date, but it keeps printing today date.
your html should be looking like this: