[Answer]-Django Templates: Accessing FK methods

1👍

✅

Since it is a forward relationship, you would just do

{{homework.assignment.get_page_url}}

Further, if you are looking for a reverse foreign key relationship, you would do

{{teacher.name}}

{% for homework in teacher.homework_set.all %}
    {{homework.due_date}}
{% endfor %}

because teacher.homework_set returns a Manager

Leave a comment