That works perfectly, thanks. I was going about it the wrong way with
values().
On Aug 14, 7:16 pm, Collin Grady <[EMAIL PROTECTED]> wrote:
> Author.objects.filter(book__publisher__id=1).distinct() doesn't work?
--~--~-~--~~~---~--~~
You received this message bec
Author.objects.filter(book__publisher__id=1).distinct() doesn't work?
--~--~-~--~~~---~--~~
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 unsub
You should be able to do this:
p = Publisher.objects.get(pk=1)
authors = Author.objects.filter(book__publisher__exact = p).distinct()
list = ([(a.id, a.name) for a in authors])
I don't have a python shell handy so I do not know for sure that the
syntax is correct, but I do things like this all
Sorry, think I've answered my own question: Further searching found a
similar request in developers a couple of months back:
http://groups.google.com/group/django-developers/browse_thread/thread/ef2d981e49ba1b4d/a4c531b8b4880cd0
Which didn't get any love. So I guess I'll need to drop in to SQL f
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,
5 matches
Mail list logo