Monday, March 30, 2020

Re: HTML code not being read

The problem might not be from the HTML template but the View.
All the HTML elements within your for loop will not display if there are no records to loop through in "comments"

On Mon, Mar 30, 2020, 3:14 PM Jeff Waters <watersjg@gmail.com> wrote:
Hi

I have written some code that allows users of a website to comment on photos in a picture gallery, using a form. However, when I test the code, no comments are displayed.

It would appear that Django is not processing the following code (from my HTML file for the photo gallery), given that 'Comment by' is not displayed on screen:

            {% for comment in comments %}
            <div class="comments" style="padding: 10px;">
                <p class="font-weight-bold">
                    <h4>Comment by</h4> {{ comment.user }}
                    <span class=" text-muted font-weight-normal">
                        {{ comment.created_on }}
                    </span>
                </p>
                {{ comment.body | linebreaks }}
            </div>
            {% endfor %}

Does anyone have any suggestions as to how I can fix this, please?

Thank you.

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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4666d2ec-e4d8-492d-8203-03dfecd29d6a%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHyB84rnKyBKR8rZbV2zij5QfK0FyA9F6DWCRo2v01QD48T%3DDQ%40mail.gmail.com.

No comments:

Post a Comment