On 04/07/2011 11:50 AM, MikeKJ wrote:
  45         try:
  46             checkview =
UserAccount.objects.all().filter(user_id=check.id).filter(video_id=pid).order_by('-datestamp',)[0]
  47         except UserAccount.DoesNotExist:
  48             checkview = None

and I get list index out of range on line 46, the whole point of the try
except is I expect the queryset to not evaluate

I think you're confusing filter and get.

   UserAccount.objects.get(user_id=check.id)

will raise a DoesNotExist if the user_id matching check.id is not found.

   UserAccount.objects.filter(user_id=check.id)

will return an empty queryset.

So as you expect, your not finding anything with your query. It's returning and empty queryset and slicing it is causing the index out of range.

--
Bryan K. Reed  bkr...@hackboy.com
'And sanity is really just a one trick pony, anyway.  I mean, all you
 get is one trick, RATIONAL THINKING!  But when you're good and crazy,
 the sky's the limit!'   -- The TICK

--
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.

Reply via email to