Suppose I'm building a large complex query on a Book (via the HTTP
query string -details omitted):
    q = Book.objects
    if year:
        q = q.filter(publication_date__year=year)
    if month:
        q = q.filter(publication_date__month=month)
    etc. (more complex queries in practice)

Now I'd like to restrict the query to books which have been printed in
'Holland':
    q = q.filter(foreign_print_set__country='Holland')

where:
    class ForeignPrint(models.Model):
        book = ForeignKey(Book)
        country = CharField()

But this is not possible on ForeignKeys. Reverse access only works for
instances, not managers.

How can I do this efficiently?

JJ.


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

Reply via email to