Take 3 models:

class Publisher(models.Model):
    name = models.CharField()

class Author(models.Model):
    name = models.CharField()

class Book(models.Model):
     publisher = models.ForeignKey(Publisher)
     authors = models.ManyToManyField(Author)

i.e. a book must have one or more authors, and must have one
publisher.

What i want is to get a distinct list of all authors for a specific
publisher. Is this possible without dropping back to raw SQL?

I want to do something like:

p = Publisher.objects.get(pk=1)
list = p.book_set.values('publisher__id', 'publisher__name').distinct()


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