I am using enumerate to find the position in a list but it doesnt seem to be working or throwing an error any ideas please?
def detail(request, item_id): item = Item.objects.get(pk=item_id) list = [] count = Item.objects.all().count() all = Item.objects.all() for y in all: list.append(y.id) get = (i for i,x in enumerate(list) if x==item_id) for i in get: raise NameError(i) if i > 0: previous = list[i - 1] if i < (count-1): next = list[i + 1] return render_to_response('news/item_detail.html',{ 'item': item,}, context_instance=RequestContext(request)) cheers -- 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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.