【发布时间】:2019-02-01 00:05:20
【问题描述】:
有没有办法将数据传递给多个 html 文件?
def topic(request, topic_id):
topic = Topic.objects.get(id = topic_id)
entries = topic.entry_set.order_by('-date_added')
videos = topic.document_set.order_by('-upload_at')
images = topic.image_set.order_by('-upload_at')
context1 = {'topic': topic}
context2 = {'entries': entries}
return render(request, 'learning_logs/entry.html', context1)
return render(request, 'learning_logs/text.html', context2)
我希望将数据传递到两个 html 文件中,但实际上只有一个被渲染/显示。
显示的 html 文件将有一个扩展链接到另一个文件。
【问题讨论】:
-
一个函数只能返回一个值。你的第二个 return 语句没有运行,因为你的函数已经返回了一些东西。
标签: python html django forms view