Good point, here are the models for all three tables. I would have thought the above would work too, but it errors: Error: Caught an exception while rendering: Error binding parameter 0 - probably unsupported type.
Here's my Table definitions. #models.py class Book(models.Model): title = models.CharField(max_length=120) slug = models.SlugField(max_length=50) authors = models.ManyToManyField(People, related_name='authors', blank=True) illustrators = models.ManyToManyField(People, related_name='illustrators', blank=True) class People(models.Model): name = models.CharField(max_length=50) slug = models.SlugField(max_length=50) is_author = models.BooleanField() is_illustrator = models.BooleanField() class Article(models.Model): title = models.CharField(max_length=120) slug = models.SlugField(max_length=50) people = models.ManyToManyField(People, blank=True) Does that all make sense, or have I got my tables set out quite badly? Thanks gang, again I'm still wrapping my head around this ... d On Jul 28, 1:59 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Jul 27, 4:13 pm, The Danny Bos <danny...@gmail.com> wrote: > > > > > > > Heya, > > > I'm currently displaying an 'Article' on a page, using the below. My > > tables are Article, People, Book. I'm in the 'Article' table, trying > > to get a list of 'Books' based on the person "selected" in Articles, > > that person needs to be the Author of the 'Books'. Dig? > > > # views.py > > def article_detail(request, slug): > > article = Article.objects.get(slug=slug) > > books = Book.objects.filter() > > > return render_to_response('articles/detail.html', {'article': > > article, 'books': books}, context_instance=RequestContext(request)) > > > All I'm missing is the "Filter", any idea how to make that look up > > between Articles.People to Books.Author? > > > Thanks, > > > d > > You haven't given enough information - you haven't stated the > relationships between the tables, and in particular how People is > related to Articles. > > But assuming that Article and Book both have a ForeignKey to People, > indicating the author, then it's quite simple: > > books = Book.objects.filter(author=article.author) > > Is that what you want? > -- > DR. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---