【发布时间】:2015-11-19 02:29:27
【问题描述】:
我有网站模板,我想在我的 django 应用程序上显示它。 我用一个应用程序创建了一个项目,并根据http://www.tangowithdjango.com/book17/chapters/templates_static.html将模板存储在模板目录中
然后我创建了一个视图来显示该模板。运行时它只显示 html,但网页中没有 css 或 javascript。当我在浏览器中打开相同的 index.html 时,它会正确显示。
我的代码:
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return render(request, 'orders/index.html')
应该是这样的::
【问题讨论】:
-
不要将你的 CSS、IMG 和 JS 放在模板文件夹中,而是放在你的静态文件夹中(在你的设置中定义)
标签: python django django-templates django-admin