[PYTHON] Django doesn't search templates under the application

It doesn't really matter, but I often forget it, so make a note.

Python 3.5.2 Django 2.2.9 Ubuntu 16.04.6 LTS (Xenial Xerus)

To get Django to look for templates under your application, you can't just say APP_DIRS``` in `TEMPLATESin settings.py.installed_apps```You need to add yourself to.

settings.py


INSTALLED_APPS = [
    'testapp',  #myself
    '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',
            ],
        },
    },

Recommended Posts

Django doesn't search templates under the application
django search
[Django] Rename the project
[Django] Test doesn't work if I change the file location