[Fixed]-Django db not printing in html table


The problem is here:

    return render(request, 'crud_app/list.html', {'lists': lists})

You are pass ‘lists’ to the context, not ‘object_list’.

Change the key to object_list, will works.

    return render(request, 'crud_app/list.html', {'object_list': lists})

Or Change the for in list.html to this:

{% for list in lists %}
    {% if list.is_active == True %} 
            <td>{{ list.last_name }}</td>
            <td>{{ list.first_name }}</td>
            <td>{{ list.id_number }}</td>
            <td>{{ list.course }}</td>
            <td><a href="">Edit</a></td> 
            <td><a href="">Delete</a></td> -->
    {% endif %}
{% endfor %}

Leave a comment