How to show the posts of the user(author)?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
28 views
models.py
class Post(models.Model): author = models.ForeignKey('auth.User', on_delete=models.CASCADE)


views.py
def beats_by_user(request, author): beats = Post.objects.get(author=author) return render(request, 'blog/beat_list.html', {'beats': beats})


urls.py
url(r'^profile_view/(?P\\w+)/$', views.beats_by_user, name='beats')


What am I doing wrong?
Post.objects.filter(author='keal')
Displays Invalid literal for int()

Although author_id displays
by | 28 views

1 Answer

0 like 0 dislike
Post.objects.filter(author__username='keal')

\rhttps://docs.djangoproject.com/en/dev/topics/db/qu...
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users