I have 3 interrelated tables:
Photos table: id ship_id etc
Ships table: id price m2 address_id etc
Address table: country region etc
I wrote this query below and it prints me out everything (price, m2 etc) from Ships but when I try to get the country and region from Address via the address_id it prints me the country and region that matches in number the ID of ships table, not the address_id of its column, So it gets me the wrong country.
builts = Photos.objects.select_related("ships", "ships__address")
** NOTE ** using prefetch_related returns the same results, does not make any difference here.
{% for x in builts %}
<tr>
<td><a href="{% url 'detailview' id=x.builtproperties.id property_type=x.builtproperties.property_type%}"><div>
<img src={{x.images.url}} width="190" height="110"></div></a></td>
<td><div> {{x.ships.address.country}}</div></td># wrong
<td><div> {{x.ships.address.region}}</div></td>#wrong
<td><div> {{x.ships.price}}</div></td>#correct
<td><div> {{x.ships.m2}}</div></td>#correct