Hi I have come up with the problem that, when I do
querySet = FollowModel.objects.filter(following = request.user.id).values_list('followed')
lis = list(querySet)
print(lis)
it prints out [(2,), (1,)]
Is there a way I can print out [2,1]
instead? So that I can extract the posts according to the people who I follow and do something like:
PostModel.objects.in_bulk(lis)
Thank you!!!
Also, my FollowModel looks like this:
class FollowModel(models.Model):
following = models.ForeignKey(
ProfileModel, related_name="who_follows", on_delete=models.CASCADE)
followed = models.ForeignKey(
ProfileModel, related_name="who_is_followed", on_delete=models.CASCADE)
follow_time = models.DateTimeField(auto_now=True)
def __unicode__(self):
return '{} follows {}'.format(self.following, self.followed) + ' at ' + str(self.follow_time)
Aucun commentaire:
Enregistrer un commentaire