On Wed, Mar 21, 2012 at 8:32 AM, Tom Evans <tevans...@googlemail.com> wrote: > On Wed, Mar 21, 2012 at 12:47 PM, Larry Martell <larry.mart...@gmail.com> > wrote: >> This is probably a stupid newbie question .... >> >> I want to access a column of data in a row using forloop.counter, but >> I cannot get it to work. >> >> In my test code, if I display {{ forloop.counter }} I get 2 >> If I display {{ headers.0.2 }} I get ToolType >> But if I display {{ headers.0.forloop.counter }} I get nothing >> >> What is the proper syntax for this? >> > > The preferred solution is to structure your data better in your view > so that writing the template to render the data is straightforward.
This is a very large existing app, and I am new at this job. That have a table of data and they want me to make some of the data in the table into links that take them to a more detailed view of the data. The functionality to provide this more detailed view of the data already exist in the app. So I am just trying to construct the href. As I iterate through the table data, I need info from the header to build the href. > > The pragmatic solution is to use a custom filter to access your > current data structures: > > http://stackoverflow.com/questions/2024660/django-sort-dict-in-template OK, but is there some reason {{ headers.0.forloop.counter } does not work when forloop.counter has a value of 2, yet {{ headers.0.2 }} does work? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.