On Thu, 2009-07-30 at 18:14 -0600, Adam Olsen wrote:
> 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?

I've written a couple of solutions for this over the years. Here's a
summary of some of them:

http://www.pointy-stick.com/blog/2009/03/10/using-djangos-aggregation-features/

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to