1👍
✅
you can access to the related model Dependency from CondRecordHdr in a template by the name set in the field with param related_name
:
prc_cond_hdr = models.ForeignKey(CondRecordHdr, related_name="dependencies",...)
# And in the template
{% for obj in obj_context %}
{% for dep in obj.dependencies.all %}
{{dep.prc_select_obj}}
{% endfor %}
{% endfor %}
Without related_name set in the field, the default related_name is set to MODENAME_set, in your case: {% for dep in obj.dependency_set.all %}
More detail in the official documentation: https://docs.djangoproject.com/en/4.1/ref/models/fields/#django.db.models.ForeignKey.related_name
Source:stackexchange.com