<cal.leem...@simplicitymedialtd.co.uk> wrote:
> Oops, sorry, that should have been:
>
> try:
> res = UserAccount.objects.all().filter(user_id=check.id
> ).filter(video_id=pid).order_by('-datestamp',)
> assert res
> checkview = res[0]
>
> except AssertionError, e:
> pass
>
Still not. Assertions are disabled when running with the -o flag, so
you'd better only use them for debugging purpose only (which is the
intended use).
Also and FWIW, the call to objects.all is useless (and costly -
cloning a queryset is not free) if you apply a filter on the resulting
queryset. idem for the second call to filter, which is functionally
equivalent to passing both criterions in the same call.
If you can't use a QuerySet.get() method, the proper code would look
like:
res = UserAccount.objects.filter(
user_id=check.id,
video_id=pid
).order_by('-datestamp',)
try:
checkview = res[0]
except IndexError:
handle_the_case_here
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment