On Mar 7, 10:43 pm, Ariel <isaacr...@gmail.com> wrote: > Could you give some idea ??? > I am sorry about the previous message I had not finished. > > Any help is appreciated. > Regards. > > > > > > > > On Mon, Mar 7, 2011 at 3:39 PM, Ariel <isaacr...@gmail.com> wrote: > > Hi everybody: > > > I would want to know in the django template tags how to get the next and > > the previous element when I am iterating in the forloop, I haven't found > > something similar, for instance I would want something like this: > > > {% for element in list_elements %} > > {{forloop.get_prev_element.title}} > > {{forloop.get_next_element.title}}
You could try using the Paginator ( http://docs.djangoproject.com/en/1.2/topics/pagination/ ) for this - giving it a limit of 1 object - and making use of its functionality for your own purposes. (You should also probably try to understand more about how iteration works in Python; for example, have a look at this discussion - http://stackoverflow.com/questions/2777188/making-a-python-iterator-go-backwards ) -- 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.