Re: list comprehension query

2013-05-03 Thread MikeKJ
Thanks Tom good points as well, between you and Gabriel it a) now works and b) is neater code.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 django-

Re: list comprehension query

2013-05-03 Thread Gabriel
Hey Mike, Great to know it's working but take a look at the rest of the stuff I and specially Tom said. You'll end up with a smaller, simpler and easier to read function. - Gabe On Fri, May 3, 2013 at 12:08 PM, MikeKJ wrote: > > Kudos Gabriel, item_id wasn't an int, I thought I'd check that 1s

Re: list comprehension query

2013-05-03 Thread MikeKJ
Kudos Gabriel, item_id wasn't an int, I thought I'd check that 1st it is now working... thank you -- 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+

Re: list comprehension query

2013-05-03 Thread Tom Evans
On Fri, May 3, 2013 at 2:32 PM, MikeKJ wrote: > 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? "Not working" is not a very good description of what is going wrong. If it did throw an error, not including it is also a b

Re: list comprehension query

2013-05-03 Thread MikeKJ
Yeah trying to debug it. I know each element will be unique as item_id is the row id of a table I just need to know it's position so I can determine if there is a previous and next and from the list get the item_id of the previous and next values in the list which will eventually be passed thr

Re: list comprehension query

2013-05-03 Thread Gabriel
Hey Mike, Could you tell us what it is that you're expecting from the code? There's a couple of things in it that I couldn't understand: 1. Why are you raising a NameError exception for every element in get? Is that supposed to be debugging to find out if the loop is running? 2. What are

list comprehension query

2013-05-03 Thread MikeKJ
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: