SSI标记不起作用。 [没有包含文件的权限]

时间:2014-09-27 14:47:29

标签: python django django-templates

我希望通过提供绝对路径在static html页面中添加html。我正在尝试使用ssi。代码是:

settings.py:

...
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
from os.path import join
TEMPLATE_DIRS = ['c:\bunker\st\static\appcache',]
ALLOWED_INCLUDE_ROOTS =[(os.path.join(BASE_DIR, 'static/appcache')),] #For access permissions
...

views.py:

from django.shortcuts import render
def home(request):
    return render(request, "a.html")

urls.py:

url(r'^apps/','sp.views.home'),  #sp is app name

a.html:

{% ssi 'C:\bunker\st\static\appcache\index.html' parsed %}

但是我从输出中获得了以下内容

  

[没有包含文件的权限]

我添加了ALLOWED_INCLUDE_ROOTS,但我仍然收到错误。

如何调试?

2 个答案:

答案 0 :(得分:0)

我通过在链接周围使用双引号解决了我的问题。例如:

{% include "index.html" %}

答案 1 :(得分:-1)

我通过将所有'\'更改为'/'来解决我的问题 编辑:您可能需要检查以确保没有其他任何内容被破坏。