Thursday, June 26, 2014

Re: Handling checkbox inputs

On Thursday, June 26, 2014 1:03:47 PM UTC+5:30, roman wrote:

the {{j.i}} can not work as you expect. If i understand you correctly
you would like to do something like getattr(list, i) in the template.

In order to do this you have 2 possibilities:

1) Write a custom template tag like this

2) Prepare the data in the view so that you can iterate over it more easily:

result  = []
for i in info:
  for j in list:
    result.append(getattr(j, i))
return render(request, 'display.html', {'result': result})

{% for r in result %}
{% endfor %}

While waiting for the reply, I worked out another method to do this. If interested you may have a look at and
I tried this too and it worked. Thanks ! 

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
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment