On Mon, May 25, 2009 at 8:04 AM, Bobby Roberts <tchend...@gmail.com> wrote:
> > pagelist=[] > > pg=WebPage.objects.filter(body__icontains=delurl) > if pg.count()>0: > for id in pg: > pagelist.append(id.url_slug) > > pg2=WebPage.objects.filter(blurb__icontains=delurl) > if pg2.count()>0: > for id in pg2: > pagelist.append(id.url_slug) > > > What is the proper way to chain filters? This is the only way I can > get it work where the body OR the blurb contains delurl. If i try to > do this: > > pagelist=[] > > pg=WebPage.objects.filter > (body__icontains=delurl,blurb__icontains=delurl) > if pg.count()>0: > for id in pg: > pagelist.append(id.url_slug) > > that results in an AND comparison and doesn't return any values. > > > If you take a look at Q objects they allow you to do just that: http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---