Show all rows in Django template

Posted under » Django on 28 May 2023

This example use a database or model. The views.py

def index(request):
    notes = Tier1.objects.all().values()
    if notes.exists(): 
            context = {'tier1': notes}
            return render(request, 'notes/contentsummary.html', context)
    else :
        return HttpResponse("You're haz no success")

The values() part is optional. Now lets look at the template

{% if tier1 %}

Tier 1 Topics

{% else %}

No notes are available

{% endif %}

Normally we want to show details from a single row

For basic array article.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS data