On Monday, April 4, 2011 4:34:10 PM UTC+1, bruno desthuilliers wrote: > > If you really did test on the very same data set, same forum, *same > thread* (IOW ; same value for "self.pk") etc, you would'nt get an > IndexError, so there's obviously something different. >
I was literally just adding the [0] and refreshing the page, doing nothing else differently. With the [0], it errors. Without the [0], I get a list with two items. The reason I posted this in here was for the very reason that I was getting an IndexError on a set that almost certainly shouldn't be empty. I also worked out that the set wasn't empty by accessing the first item from the template instead (i.e. adding '.0' to the end of the value in the template tag, instead of [0] to the end of the return function in the model). > ... > > This returns all posts, whatever thread they belongs to. > I know, I was trying to point out that the change in behaviour when I add the [0] is most likely due to the filter command. > It's not "causing it to return an empty queryset", it's raising an > index error because your queryset is already empty. > If you know of a better way I can test it, I'd appreciate it, it will come in useful if something like this happens again. I've since gone another route to avoid having to use the function (this was bugging the hell out of me), but thanks for your help + suggestion. Adam > > -- 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.