On Fri, Feb 20, 2009 at 9:43 AM, Peter Müller <abacom.t...@googlemail.com> wrote: > I want to select all Posts where text contains "Some Text" or > Attachment.name (which is related to one post) contains "Some Text". > Is there a way to do this with Django's ORM?
This is covered in the "Making queries" documentation (http://docs.djangoproject.com/en/dev/topics/db/queries/). Specifically, you'll want to look at the sections about related objects (http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects) and complex lookups (http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects). Read through that, and hopefully you'll understand the answer, which looks something like:: Post.objects.filter(Q(text__contains='some text') | Q(attachment__name__contains='some text')) Jacob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---