14
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TemplateDoesNotExist at とか言われたら

Last updated at Posted at 2015-03-07

なんかよくわかってないけど、Djangoでタイトルのエラーが出た。
簡単な話なんだろうけど備忘録的に。

Django tried loading these templates, in this order: Using loader django.template.loaders.filesystem.Loader: Using loader django.template.loaders.app_directories.Loader: C:\Python34\lib\site-packages\django\contrib\admin\templates\cms\book_list.html (File does not exist) C:\Python34\lib\site-packages\django\contrib\auth\templates\cms\book_list.html (File does not exist) C:\Python34\lib\site-packages\bootstrapform\templates\cms\book_list.html (File does not exist)

色々探したけれど見つからないの、ゴメンね。と言われた。

settings.pyに
 TEMPLATE_DIRS = (   os.path.join('mybook', 'templates'),  )
※mybookはアプリ名、templatesはアプリフォルダ配下のテンプレートが置いてあるフォルダ。

そしたらLoaderが見つけてくれましたとさ。

settings.pyのある場所の配下で探すみたいなので↓を追加したほうがスマートらしい。
SETTINGS_PATH = os.path.normpath(os.path.dirname(__file__)) TEMPLATE_DIRS = (   os.path.join(SETTINGS_PATH, 'templates'), )
なんかこんな感じ。

14
16
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?