logo       

Simple query on a ManyToMany field?: msg#02230

DjangoUsers

Subject: Simple query on a ManyToMany field?


Suppose I have the following models:

class Tag(models.Model):
card = models.ForeignKey('Card')
name = models.CharField(max_length=10)

class Card(models.Model):
# whatever....

Say I have a list, like the following: words = ['christmas', 'mother']

This list can be of variable length. How can I write a query that
will return a list of Card objects that match ALL (not any) of the
words? Is there a way to do it in a line or two without traversing
all of the card objects?

--
Adam Olsen
http://www.vimtips.org
http://last.fm/user/synic

--~--~---------~--~----~------------~-------~--~----~
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@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
django-users+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise