我需要在模板文章和用戶名中顯示這篇文章。型號「後」具有ForeignKey給用戶。django在模板中獲取相關外鍵
{% for post in post_list %}
<tr>
<td>{{ post.user_name }}</td>
<td>{{ post.user_name }}</td>
<td>{{ post.post_user.user_name }}</td>
<td>{{ post.post_content }}</td>
</tr>
{% endfor %}
class user(models.Model):
user_name = models.CharField(max_length=25)
class post(models.Model):
post_content = models.CharField(max_length=65000)
post_user = models.ForeignKey(user)
沒有任何辦法,我試圖不工作