Как вывести данные списка в следующей строке в Django
Здесь я получаю некоторые данные в список через цикл for и это должно быть выведено в следующей строке
Рассмотрим мой файл views.py как
def items_log(request, pk):
logg = []
client = request.user.client
items_log = JobItemsLogs.objects.filter(client=client,item_id=pk).order_by('-id')[:5]
for x in items_log:
log_text = 'Type of entry: {0} - date: {1}; Created by: {2}'.format(
x.type_of_entry,x.created_at.date(),x.created_by)
logg.append(log_text)
...
...
...
Теперь рассмотрим файл index.html как
<div class="span4">
<div class="well">
<ul class="nav nav-list">
<li class="nav-header" >Log entries</li>
{% for i in logg %}
{{i}}
{% endfor %}
</ul>
</div>
</div>
Вот как это отображается
как я хотел отобразить
Type of entry: Plumbing - date: 2021-11-02; Created by: A Krishna*
Type of entry: Plumbing - date: 2021-11-02; Created by: A Krishna*
Type of entry: None - date: 2021-07-28; Created by: A Krishna*
Type of entry: None - date: 2021-07-28; Created by: A Krishna*
Type of entry: None - date: 2021-07-28; Created by: A Krishna*
Каждый из этих списков данных должен отображаться в новых строках
Просто поместите {{i}}
внутрь тега p
! :D
<p>{{i}}</p>
Или вы можете добавить <br>
:
{{i}}<br>
Добавьте символ разрыва строки после строки -
log_text = 'Type of entry: {0} - date: {1}; Created by: {2}<br>'.format(
x.type_of_entry,x.created_at.date(),x.created_by)