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 > view by year method. If there are no posts, I want to raise a http404. > > I've tried == {} and == [] to no avail. > > Thanks, > > - James > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---