Hello everyone,
-- I am trying to do the following:
Grab Year/Month values from a template page via dropdown select list and send them via ajax post (this part is working)
Process the submitted values and return new variables to the same template page, it works if I hard code the Month/Year but it won't display anything when I change values and re-submit them.
In the console I can print selected Month/Year and values for the 3 variables without any issues, but the template page is not displaying anything
Thanks!
here is my code:
page.html
{% for item1, item2, item3 in list_results %}
<td>{{ item1 }}</td>
<td>{{ item2 }}</td>
<td>{{ item3 }}</td>
</tr>
{% endfor %}
views.py
def data_web(request):
if request.method == 'POST':
year = request.POST.get('the_year')
month = request.POST.get('the_month')
year = int(year)
month = int(month)
var1, var2, var3 = count_files(year, month)
list_results = zip(var1, var2, var3)
print "Year", year, "month", month, list_results
return render(request, 'page.html', {'list_results': list_results})
else:
return render(request, 'page.html')
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e4a5ea8f-3b44-44d8-8946-7e6d7f131463%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment