Answer the question
In order to leave comments, you need to log in
How to display the posts of the user (author)?
models.py
class Post(models.Model):
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
def beats_by_user(request, author):
beats = Post.objects.get(author=author)
return render(request, 'blog/beat_list.html', {'beats': beats})
url(r'^profile_view/(?P<author>\w+)/$', views.beats_by_user, name='beats')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question