Django query filter a set of data
Posted
by dana
on Stack Overflow
See other posts from Stack Overflow
or by dana
Published on 2010-06-18T15:03:26Z
Indexed on
2010/06/18
15:23 UTC
Read the original article
Hit count: 270
if a have a query like
following = Relations.objects.filter(initiated_by = request.user)
in which i'm having all the users followed by the currently logged in user, and i want to display those user's blog posts. Using a query like:
blog = New.objects.filter(created_by = following)
it only shows me the blog posts of the user with the id = 1 (though the currently logged in user doesn't actually follow him) in template i have :
{% for object in blog %}
<a href='/accounts/profile_view/{{object.created_by}}/'> {{object.created_by}}</a> <br />
{{object.post}}<br />
{% endfor %}
Where am i wrong?
© Stack Overflow or respective owner