I'm getting values
from form
in django
like this:
tantou1 = request.POST.get("1tantou", "")
tantou2 = request.POST.get("2tantou", "")
tantou3 = request.POST.get("3tantou", "")
tantou4 = request.POST.get("4tantou", "")
hidzuke1 = request.POST.get("1hidzuke", "")
hidzuke2 = request.POST.get("2hidzuke", "")
hidzuke3 = request.POST.get("3hidzuke", "")
hidzuke4 = request.POST.get("4hidzuke", "")
which works, but I have a lot of values to get and this way took too much space in my code. I would like to ask, if there is not a way to define this variables in (for example) loop? Something like:
data_vars = [tantou1="", tantou2="", tantou3="", tantou4="", hidzuke1="", hidzuke2="", hidzuke3="", hidzuke4=""]
for var in data_vars:
var = request.POST.get(str(var.__name__), "")
or so?