0

テンプレートを確認するために、settings.py にディレクトリを設定しました。

TEMPLATE_DIRS = (
    '/var/www/templates/',
)

次のようなディレクトリ構造で

/var/www/templates/
|__footer.html
|__header.html
|__index/
   |__index.html

ヘッダーとフッターを正常にソースできます

>>> render_to_response('footer.html')
    <django.http.response.HttpResponse object at 0x2268d10>

しかし、サブディレクトリにはありません

>>> render_to_response('index/index.html')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/var/www/local/lib/python2.7/site-packages/django/shortcuts/__init__.py", line 29, in render_to_response
    return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
  File "/var/www/local/lib/python2.7/site-packages/django/template/loader.py", line 172, in render_to_string
    return t.render(Context(dictionary))
  File "/var/www/local/lib/python2.7/site-packages/django/template/base.py", line 140, in render
    return self._render(context)
  File "/var/www/local/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
    return self.nodelist.render(context)
  File "/var/www/local/lib/python2.7/site-packages/django/template/base.py", line 830, in render
    bit = self.render_node(node, context)
  File "/var/www/local/lib/python2.7/site-packages/django/template/debug.py", line 74, in render_node
    return node.render(context)
  File "/var/www/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 166, in render
    template = get_template(template_name)
  File "/var/www/local/lib/python2.7/site-packages/django/template/loader.py", line 146, in get_template
    template, origin = find_template(template_name)
  File "/var/www/local/lib/python2.7/site-packages/django/template/loader.py", line 139, in find_template
    raise TemplateDoesNotExist(name)
TemplateDoesNotExist
4

1 に答える 1