i have three table
<code>#post that user create
class Post(models.Model):
title = models.CharField(max_length=255)
content = models.TextField(help_text='type something')
author = models.ForeignKey(User,on_delete=models.SET_NULL,null=True)
#....
#comment has related to uniqe post
class Comment(models.Model):
post = models.ForeignKey(Post,on_delete=models.CASCADE)
name = models.CharField(max_length=255)
#....
#userprofile get image for each user has sign up befor
class UserProfile(models.Model):
user = models.ForeignKey(User,on_delete=models.CASCADE)
avatr = models.ImageField()
comment = models.ForeignKey(Comment,on_delete=models.CASCADE)
</code>
<code>#post that user create
class Post(models.Model):
title = models.CharField(max_length=255)
content = models.TextField(help_text='type something')
author = models.ForeignKey(User,on_delete=models.SET_NULL,null=True)
#....
#comment has related to uniqe post
class Comment(models.Model):
post = models.ForeignKey(Post,on_delete=models.CASCADE)
name = models.CharField(max_length=255)
#....
#userprofile get image for each user has sign up befor
class UserProfile(models.Model):
user = models.ForeignKey(User,on_delete=models.CASCADE)
avatr = models.ImageField()
comment = models.ForeignKey(Comment,on_delete=models.CASCADE)
</code>
#post that user create
class Post(models.Model):
title = models.CharField(max_length=255)
content = models.TextField(help_text='type something')
author = models.ForeignKey(User,on_delete=models.SET_NULL,null=True)
#....
#comment has related to uniqe post
class Comment(models.Model):
post = models.ForeignKey(Post,on_delete=models.CASCADE)
name = models.CharField(max_length=255)
#....
#userprofile get image for each user has sign up befor
class UserProfile(models.Model):
user = models.ForeignKey(User,on_delete=models.CASCADE)
avatr = models.ImageField()
comment = models.ForeignKey(Comment,on_delete=models.CASCADE)
i try to have user profile image when show comments for any user
can we call image when users comment has picture
<code>post=get_object_or_404(Post,pk=pid,status=1)
#......
</code>
<code>post=get_object_or_404(Post,pk=pid,status=1)
#......
</code>
post=get_object_or_404(Post,pk=pid,status=1)
#......
<code>comment = Comment.objects.filter(post=post.id,)
#like this i want to have my comment details
{% for comment in comment %}
{{comment.name}}
{{comment.userprofile.image.url}}
</code>
<code>comment = Comment.objects.filter(post=post.id,)
#like this i want to have my comment details
{% for comment in comment %}
{{comment.name}}
{{comment.userprofile.image.url}}
</code>
comment = Comment.objects.filter(post=post.id,)
#like this i want to have my comment details
{% for comment in comment %}
{{comment.name}}
{{comment.userprofile.image.url}}
New contributor
Hesam Sadat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2