If you’ve worked with Django for any length of time, you’ve probably encountered the frustrating “Template Does Not Exist” error. I’ve helped fellow developers troubleshoot this error. Despite its frequent appearance, the fix is often simple once you understand what’s going on under the hood.
In this article, I’ll walk you through several practical methods to resolve this error. These solutions will help you get your Django app rendering templates smoothly again.
Let’s get in!
What Causes the “Template Does Not Exist” Error?
This error occurs when Django tries to render a template but cannot find the specified HTML file in any of the directories it knows about. Common reasons include:
- Misconfigured
TEMPLATESsettings in yoursettings.py - Templates placed in the wrong directory
- Typos in template names or paths in your views
- Forgetting to add your app to
INSTALLED_APPS
Understanding these causes will help you quickly identify the root of the problem.
Check out How to Get the Current Time in Django
Method 1: Verify Your TEMPLATES Setting in settings.py
The first place to check is your Django settings file. The TEMPLATES setting tells Django where to look for template files.
Here’s a typical TEMPLATES configuration that works for most projects:
# settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')], # Custom templates folder
'APP_DIRS': True, # Enables template loading from each app's templates folder
'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',
],
},
},
]Key points to check:
DIRSshould include the path(s) where your templates live outside of apps.APP_DIRSset toTrueallows Django to look inside each app’stemplatesfolder.- Make sure
BASE_DIRis correctly defined.
You can see the output in the screenshot below.

Check out Create a Notes Taking app in Django
Method 2: Organize Your Template Files Properly
Django looks for templates in specific locations depending on your settings.
Option A: Project-Level Templates Folder
If you use the DIRS setting as above, create a folder named templates at the root of your project (same level as manage.py). Place your HTML files here.
Example structure:
myproject/
├── manage.py
├── myapp/
├── templates/
│ └── home.htmlIn your view:
from django.shortcuts import render
def home_view(request):
return render(request, 'home.html')Option B: App-Level Templates Folder
If you rely on APP_DIRS=True, place templates inside your app folder under templates/app_name/.
Example structure:
myproject/
└── myapp/
├── templates/
│ └── myapp/
│ └── home.html
├── views.pyIn your view:
def home_view(request):
return render(request, 'myapp/home.html')Note: The subfolder inside templates should match your app’s name to avoid template name collisions.
You can see the output in the screenshot below.

Read Build a To-Do List API in Django Rest Framework
Method 3: Check Your Template Name and Path in Views
Typos in the template name or path are a subtle but common cause.
- Make sure the template name in your
rendercall exactly matches the file name, including extension. - If your template is inside a subfolder, include that in the path (
'app_name/template.html').
For example:
return render(request, 'myapp/home.html')If your template is at templates/myapp/home.html.
Method 4: Add Your App to INSTALLED_APPS
If you’re using app-level templates, Django only searches inside apps listed in INSTALLED_APPS.
Check your settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
# other default apps
'myapp', # Your app here
]If your app is missing, Django won’t find templates inside its folder.
Check out Use Django Built-In Login System
Method 5: Clear Cache and Restart the Server
Sometimes changes don’t reflect immediately because of caching or server state.
- Stop your development server (
Ctrl+C). - Clear
.pycfiles if needed. - Restart the server with:
python manage.py runserverThis often resolves lingering template loading issues.
Bonus: Debugging Template Paths
If you want to see where Django is looking for templates, you can add some debug prints in your view or use Django’s shell:
from django.template.loader import get_template
try:
template = get_template('home.html')
print("Template found:", template.origin)
except TemplateDoesNotExist as e:
print("Template not found:", e)This will show you the exact filesystem path Django is trying to load.
Read Google Authentication in Django
Full Example: Minimal Django App Fixing the Template Error
Here is a minimal example that demonstrates the correct setup.
Project structure:
myproject/
├── manage.py
├── myproject/
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── myapp/
│ ├── __init__.py
│ ├── views.py
│ ├── urls.py
│ └── templates/
│ └── myapp/
│ └── home.html
└── templates/settings.py snippet:
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp', # Add your app here
]
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',
],
},
},
]myapp/views.py:
from django.shortcuts import render
def home_view(request):
return render(request, 'myapp/home.html')myapp/urls.py:
from django.urls import path
from .views import home_view
urlpatterns = [
path('', home_view, name='home'),
]myproject/urls.py:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('myapp.urls')),
]myapp/templates/myapp/home.html:
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
</head>
<body>
<h1>Welcome to my Django App!</h1>
</body>
</html>Run your server and visit http://127.0.0.1:8000/ you should see the home page without any template errors.
Getting the “Template Does Not Exist” error is a rite of passage for Django developers, but with these methods, you can quickly pinpoint and fix the problem. Keeping your templates organized, double-checking your settings, and verifying template paths will save you hours of frustration.
If you follow these steps carefully, your Django apps will render templates flawlessly, letting you focus on building great features.
You may read:

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.