I want to show in an Html the name of the city, state, and country of a publication. But they are in different tables.
Here is my models.py
You don't need an INNER JOIN nor select_related
for this simple case, because you can traverse directly in template to the city
, countrystate
, and country
– based on what I just experienced in my project.
Since your QuerySet is set via context dic['plist']
, then, in template you can just:
{% for itero in plist %}
{{ itero.title }}
{{ itero.city.city_name }}
{{ itero.citystate.citystate_name }}
{{ itero.country.country_name }}
{% endfor %}