[Django]-Django – templatedoesnotexist

1πŸ‘

βœ…

I had the same problem saying template does not exist and I solved it by changing the URL pattern in my views.py where previously I had mentioned just date.html, later I edited with blog/date.html. Hope it might help you.

πŸ‘€yogesh

2πŸ‘

I solved it by adding forward slash "/" after β€˜templates’:

'DIRS': [BASE_DIR / 'templates/'],
πŸ‘€Taregh Naderi

1πŸ‘

I assume 'INSTALLED_APP' is a typo and it really says 'INSTALLED_APPS' in your settings. Anyway, you need to set APP_DIRS = True for templates to be found in app/templates
folders:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
                 os.path.join(BASE_DIR, 'templates'),
                 ],
        'APP_DIRS': True,  # this line is important
        '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'
                # ...
            ]
        },
    },
]
πŸ‘€user2390182

1πŸ‘

me having the same issue,
added the app to the INSTALLED_APPS
done, because you (and me) were using the templates not in the main app so it must be registered in the settings (like referring to the urls of the app from the main urls file)

πŸ‘€mohaa8844

0πŸ‘

Go to your setting.py and try something like:

os.path.join(BASE_DIR, "templates")

For example:

TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR, "templates")],
    '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',
        ],
    },
},

]

πŸ‘€Gabriel

0πŸ‘

For me, it was using rest_framework without adding it to INSTALLED_APPS.

πŸ‘€aviv avital

Leave a comment