How about result_set.count()>0, if it's a queryset object, or
len(result_set)>0 if it's a list?
On May 7, 5:05 pm, "Guillaume Lederrey" <[EMAIL PROTECTED]>
wrote:
> 2008/5/6 jwwest <[EMAIL PROTECTED]>:
>
> > What's the preferred method of checking to see if a result set is
> > empty in a view?
2008/5/6 jwwest <[EMAIL PROTECTED]>:
> What's the preferred method of checking to see if a result set is
> empty in a view? For instance, I'm writing blog software and have a
> view by year method. If there are no posts, I want to raise a http404.
>
> I've tried == {} and == [] to no avail.
M
try this:
result_set = Model.objects.all()
if result_set:
result_set has data
else:
result_set is empty
On 5/6/08, jwwest <[EMAIL PROTECTED]> wrote:
>
> What's the preferred method of checking to see if a result set is
> empty in a view? For instance, I'm writing blog software and have a
What's the preferred method of checking to see if a result set is
empty in a view? For instance, I'm writing blog software and have a
view by year method. If there are no posts, I want to raise a http404.
I've tried == {} and == [] to no avail.
Thanks,
- James
--~--~-~--~~--
4 matches
Mail list logo