Re: Select a list item by index

2008-11-07 Thread Daniel Roseman
On Nov 7, 4:11 pm, jago <[EMAIL PROTECTED]> wrote: > Sure. > >                 {% for gallerykind in gallerykinds %} >                         >                                         {{ gallerykind.title }} > >                                         {% if gallerykind.author %} >              

Re: Select a list item by index

2008-11-07 Thread jago
Sure. {% for gallerykind in gallerykinds %} {{ gallerykind.title }} {% if gallerykind.author %} by {{ gallerykind.author }}

Re: Select a list item by index

2008-11-07 Thread Daniel Roseman
On Nov 7, 2:12 pm, jago <[EMAIL PROTECTED]> wrote: > I tried the slice solution before. Unluckily it returns a list itself > holding 1 item instead of the item itself. Most importantly though I > cannot use a variable like forloop.counter0 to select the item I want > but instead can only use stati

Re: Select a list item by index

2008-11-07 Thread jago
I tried the slice solution before. Unluckily it returns a list itself holding 1 item instead of the item itself. Most importantly though I cannot use a variable like forloop.counter0 to select the item I want but instead can only use static numeric values like 1,2,3 On Nov 7, 10:39 am, Daniel Ros

Re: Select a list item by index

2008-11-07 Thread jago
Obviously I want to select for each iteration another item from the array. Unluckily something like: arr.forloop.counter0 forloop.counter0 is the variable that holds the currently used index in a for loop: http://www.djangoproject.com/documentation/0.96/templates/#for Any idea how I could selec

Re: Select a list item by index

2008-11-07 Thread Daniel Roseman
On Nov 7, 12:52 am, jago <[EMAIL PROTECTED]> wrote: > I have a for loop over a list A. > > inside the loop I want to print out the item of list B at the index > 'forloop.counter0' of list A. > > It is really strange. One can select randon items in a list, or the > first item in a list, but I did n

Re: Select a list item by index

2008-11-07 Thread Raja
You can use something like {{ array.index}} to get the value of a specific index. For e.g. arr = [1,2,3,4] In view, if I do a {{ arr.1 }}, it should return 2 -- Raja On Nov 7, 5:52 am, jago <[EMAIL PROTECTED]> wrote: > I have a for loop over a list A. > > inside the loop I want to print out t

Re: Select a list item by index

2008-11-07 Thread Alex Koshelev
The is not way to get list item by variable index with standard django template tags. On Fri, Nov 7, 2008 at 03:52, jago <[EMAIL PROTECTED]> wrote: > > I have a for loop over a list A. > > inside the loop I want to print out the item of list B at the index > 'forloop.counter0' of list A. > > It