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