V
V
volkov12feb2022-03-23 19:26:59
Django
volkov12feb, 2022-03-23 19:26:59

How to display data from the database in Django Templates separated by commas?

Good afternoon. I can't find an answer to my question. I have a list of people that should be displayed on the site from the database. I made a conclusion. But there is one BUT. Everything is displayed in a row, without commas. I found an output option using |join:", " , but in this case a comma is placed after each letter. How to be? Thank you!
623b4a05e4deb314115641.png
623b4a0e40f07248866423.png

<li style="list-style: none"><span><b>Актеры:</b>
    {% for actor in movie.actors.all %}
        <a href="{% url 'actor_detail' actor.name %}">{{ actor.name }}</a>
    {% endfor %}
</span></li>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-03-23
@volkov12feb

You need to put a comma after the Homework tag , read the doc https://docs.djangoproject.com/en/4.0/ref/template... and tell how not to put a comma for the last actor </a>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question