DJANGO : How to iterate a ListView items to convert in cards
I am coding an app "dash" how a startpoint to many users. "a applications dashboard". I want to convert the list of applications in cards, "portfolio style".
the user login in the platform, and in the url .../dash open the dash(django app). To here it's perfect.
with the generic view - ListView - we obtain the list of applications will be available in the platform (if exist in the model, the application it's installed and available to the user)
urls.py:
path('dash/', views.ListView_Dash_Apps.as_view()),
views.py:
class ListView_Dash_Apps(ListView):
template_name = "dash/ListarAplicaciones.html"
model = App
and in the html template, How to iterate the columns of the object_list??? with this i can iterate the rows, but not the column, i receive the str output declarated in the model.
<ul>
{% for e in object_list %}
<li>{{ e }}</li>
{% endfor %}
</ul>
If i can to read the columns data and include in the html (App, url_app, icon, etc etc..)
In the HTML, the columns are methods of the object_list.
in my case, e.appcode, e.url and e.description
<ul>
{% for e in object_list %}
<li>{{ e }}</li>
{% endfor %}
</ul>
Finally:
{% for e in object_list %}
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="" alt="">
<div class="card-body">
<h5 class="card-title">{{e.appname}}</h5>
<p class="card-text">{{e.description}}</p>
<a href={{ e.url }} class="btn btn-primary">Abrir</a>
</div>
</div>
{% endfor %}