How To Get A Django Template To Pull Information From Two Different Models?
I am coding a basic django application that will show a table of current store sales, based off of information from a MariaDB database. The data is entered into the database throu
Solution 1:
The storeid
field on the ShowroomData model of actually a foreign key. So you should declare it as such:
classShowroomData(models.Model):
store = models.ForeignKey("Stores", db_column="storeid")
Now you can follow that fk in your template. Assuming current_showroom
is a queryset of ShowroomData instances:
{% for store in current_showroom %}
<tr>
<td>{{ store.storeid }}</td>
<td>{{ store.store.name }}</td>
</tr>
{% endfor %}
Post a Comment for "How To Get A Django Template To Pull Information From Two Different Models?"