我只想显示与特定帖子相关的特定卡片:
当前问题:
Internal Server Error: /board/table/card/create/
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\django\core\handlers\excepti
on.py", line 41, in inner
response = get_response(request)
答案 0 :(得分:0)
您可以通过board.cards
def board_detail(request, slug):
board = get_object_or_404(Board, title=slug)
cards = board.cards
# ___________^
template = 'board/board_detail.html'
context = {'board': board, 'cards': cards}
return render(request, template, context)
然后在你的模板中:
{% for card in cards %}
<p>{{ card.title_card }}</p>
{% endfor %}
答案 1 :(得分:0)
为什么要访问卡的模型管理器?如果您只想要该卡的卡,请尝试board.cards。你可以进一步过滤