I’ve got a model class, House, with several columns. I want to get all the entries to this table, with all the columns, and display these on in a table in a template.
Firstly, how do I pull all the information that I need out of the database (and into a 2d list?), and what tag could I use to access specific data in the table?
it’s as easy as stated here
so, practically:
will give you all the entries in your database.
from within a view, pass that variable to the template context then, in the template:
let me explain this bit of code: once you pass all your entries to the template, you can loop them with {% for %}
{{ house. }} means that you can extract the value you need from the column you need ( column_name ) and place it wherever you want (from whitin the for loop, obviously) so you can have (for example) {{ house.price }}, {{ house.bathrooms }} and so on, for each entry you have in your “all_entries”