[Fixed]-Comments not displaying in Django application

1👍

You are not passing any object called post into the template for rendering.

You need to change either the context passed from the view:

context = {
    "title": instance.title,
    "photo": instance,
    "share_string": share_string,
}

Or change the code in the template:

{% for comment in instance.comments.all %}

(one or the other, not both)

I would suggest to change the context in the view to use the more meaningful name photo.

Leave a comment