LoginSignup
0
0

More than 3 years have passed since last update.

Django TemplateDoesNotExist at /が出た!(単純なのに半日ハマった!)

Last updated at Posted at 2020-03-08

 ■環境

 windows10
 Pycharm Community 2019.3
 Python3.7
 Django 3.03

■前提条件

 Djangoプロジェクト、アプリケーション作成していることを前提。以下参照
 ターミナルでDjangoアプリケーション作成まで

■事象

index.htmlを読みに行ったら、「TemplateDoesNotExist at /」が
出て、index.htmlが出てこない!

image.png

■試したけど、駄目だったこと

いろいろ調べて、以下やってみたけど、変わらず・・

① setting.py の TEMPLATES = 内を以下のように修正

 'DIRS': [],
  ↓
 'DIRS': [BASE_DIR, "templates"],

② setting.py の TEMPLATES = 内を以下のように修正

 'DIRS': [],
  ↓
'DIRS': [os.path.join('app_private_diary','templates')],

■原因

そもそも、このエラー、ファイルが存在しないか?ファイルが読み込めないエラー。

さっきのエラーを見てみると

image.png

index.html を読みたいのに、index\html と表示されていることがわかる。

view.pyを見ると、index\html になっていることがわかる。

image.png

index/html → index.html

に変更したら、エラー解消しました。

基本的なやつでした(泣)。

以上

0
0
0

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
0
0