0
1

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 3 years have passed since last update.

Djangoがアプリケーション下のtemplatesを検索してくれない

Posted at

ほんとうにどうでもいいことなんだけどよく忘れるのでメモ。

Python 3.5.2
Django 2.2.9
Ubuntu 16.04.6 LTS (Xenial Xerus)

Djangoにアプリケーション下のtemplatesを探してもらうにはsettings.pyのTEMPLATESAPP_DIRSがTrueだけではだめなんです。
INSTALLED_APPS に自分自身を追加する必要があります。

settings.py


INSTALLED_APPS = [
    'testapp',  #自分自身
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]


TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?