Thanks Andreas

I think that one of the mistakes I'd made previously was to not associate 
particular comments with particular pictures. 

I've tried to rectify that using the code below. However, when I do this, the 
page I get is empty. 

Any advice would be appreciated:

{% extends 'nowandthen/base.html' %}
{% block body_block %}
<br>
<br>
{% if pictures %}
    <ul>
    {% for p in Picture.objects.all %}
<div class="container">
  <div class="row">
    <div class="col-md-8 card mb-4  mt-3 ">
        <!-- Card -->

  <!-- Card content -->
            <div class="card-body d-flex flex-row">

    <!-- Content -->
                <div>

      <!-- Title -->
                    <h4 class="card-title font-weight-bold mb-2">{{ p.title 
}}</h4>
      <!-- Subtitle -->
                    <p class="card-text"><i class="far fa-clock pr-2"></i>{{ 
p.when_added }}</p>
                </div>
            </div>

  <!-- Card image -->
            <div class="view overlay">
                <img class="card-img-top rounded-0" src="{{ p.image.url }}" 
alt="Card image cap">
                    <a href="#!">
                        <div class="mask rgba-white-slight"></div>
                    </a>
            </div>

  <!-- Card content -->
            <div class="card-body">
                <div class="collapse-content">

      <!-- Text -->
                    <p class="card-text collapse" id="collapseContent">{{ 
p.description }}</p>
      <!-- Button -->
                    <a class="btn btn-flat red-text p-1 my-1 mr-0 mml-1 
collapsed" data-toggle="collapse" href="#collapseContent" aria-expanded="false" 
aria-controls="collapseContent">Click for description</a>
                    <i class="fas fa-share-alt text-muted float-right p-1 my-1" 
data-toggle="tooltip" data-placement="top" title="Share this post"></i>
                    <i class="fas fa-heart text-muted float-right p-1 my-1 
mr-3" data-toggle="tooltip" data-placement="top" title="I like it"></i>

                </div>
            </div>
            <div class="card-body">
        <!-- comments -->
                <h2>comments</h2>
                {% if not p.comments %}
                No comments
                {% endif %}
                {% for x in p.comment %}
                <div class="comments" style="padding: 10px;">
                    <p class="font-weight-bold">
                        <h4>Comment by</h4> {{ x.user }}
                        <span class=" text-muted font-weight-normal">
                            {{ x.created_on }}
                        </span>
                    </p>
                    {{ x.body | linebreaks }}
                </div>
                {% endfor %}
            </div>
            <div class="card-body">
                {% if new_comment %}
                <h2>Your comment has been posted.</h2>
                {% else %}
                <h3>Leave a comment</h3>
                <form action="{% url 'nowandthen:add_comment' p.image_id %}" 
method="POST">
                    {{ comment_form.as_p }}
                    {% csrf_token %}
                    <button type="submit" class="btn btn-primary  
btn-lg">Submit</button>
                {% endif %}
            </div>
    </div>
  </div>
</div>
<!-- Card -->
    {% endfor %}
    </ul>
{% else %}
    <li><strong>There are no photographs present.</strong></li>
{% endif %}

{% endblock %}


Thanks

Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7a56b57b-42e9-42be-bc9f-3ed8714cf444%40googlegroups.com.

Reply via email to