The reverse of '‘topic_posts’ works fine in other places. But it doesn’t work here.
HTML file
<td class="align-middle">
{% with post=board.get_last_post %}
<small>
<a href="{% url 'topic_posts' board.id post.topic.id %}">
By {{ post.created_by.username }} at {{ post.created_at }}
id - {{ board.id }} {{ post.topic.id }}
</a>
</small>
{% endwith %}
</td>
url setting
path('boards/<int:board_id>/topics/<int:topic_id>/', views.topic_posts, name='topic_posts'),
def topic_posts(request, board_id, topic_id):
topic = get_object_or_404(Topic, board_id=board_id, id=topic_id)
return render(request, 'topic_posts.html', {'topic': topic})
When I changed the board.id
and post.topic.id
to integer value , for exmaple 1 and 24, the web would render. I commented <a href="{% url 'topic_posts' board.id post.topic.id %}">
and added {{ board.id }} {{ post.topic.id }}
to see if there is an error with the query, turned out there is no problem, it would render 1, 24 on the webpage. Then I tried <a href="{% url 'topic_posts' board.id 24 %}">
It worked fine, but <a href="{% url 'topic_posts' board.id post.topic.id %}">
still won’t work.
Thanks for reading!