Blog available for sell
This blog is available for sale. Please 'contact us' if interested.
Advertise with us
templates django-error   8   64627
Solving Django Error: TemplateDoesNotExist at /app_name/

TemplateDoesNotExist at /app_name/

If you are facing above template error, there is a high possibility that at-least one of the below listed point applies to you.

1. Wrong template name:

Make sure when rendering the template, you are using right name of template. 

return render(request, 'app_name/tools.html', data)

Check if template name is actually tools or it is tool?

2. Wrong app name:

In the above render statement, confirm if the appname used is correct or not.

return render(request, 'app_name/tools.html', data)

3. Installed Apps:

Please confirm if your app is listed in installed apps in file.


4. Template Directory Structure:

Make sure your templates are places inside a directory with same name as your app's name which in itself is inside templates directory. Confused? 

So your templates directory structure should be as below.

|    |-app_name
|    |    |-tools.html

5. Where is Django looking for templates:

Confirm if Django is looking for templates in app directories. For this you need to see templates setting in file. Check if APP_DIR is set to True. If this is set to False, Django won't look for templates in app directories.

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'context_processors': [

6. Project level templates:

If you are using something like below in your project's file

urlpatterns += [
path(r'robots.txt/', TemplateView.as_view(template_name="project_name/robots.txt", content_type='text/plain')),

It could be any file instead of robots.txt, then make sure there is templates directory in root directory of project. This template directory is outside of every app. Directory structure would be as below.

|    |-templates
|    |    |-project_name
|    |    |    |-your-template-here

These template files are project level template files.

Also add 'DIRS': [os.path.join(BASE_DIR, 'templates')],  in TEMPLATES tuple in file. BASE_DIR is defined in file at the top. If not define as below.

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

If you are still unable to resolve the error, feel free to comment or contact us or connect on facebook page.

Host your Django project for free.

templates django-error   8   64627
8 comments on 'Solving Django Error: Templatedoesnotexist At /App_Name/'
Login to comment

Lary Jan. 20, 2019, 10:22 a.m.
This was very helpful. Thanks a lot.
Pahang Krisdyan March 29, 2019, 2:03 p.m.
I just relize that i haven't add my new app to installed app
Himanshu July 16, 2019, 10:53 a.m.
Thanks man
Renan Vieira Mechetti Ferreira July 17, 2019, 9:53 p.m.
What means abspach(__file__)?
Ashish Vyas Aug. 21, 2019, 6:06 p.m.
STATIC_ROOT = os.path.join(BASE_DIR,'static')STATIC_URL = '/static/'STATICFILES_DIR = [ os.path.join(BASE_DIR,'course_project/static/')]i have this code in my django still i am getting the error 404 message
Neha Kumari July 12, 2020, 2:35 p.m.
hey thanku so much
Manikanta July 29, 2020, 2:38 a.m.
guys help me i have starta django projet but there is a error raise lot of a time TEMPLATE DOSE NOT EXIT AT plz help me how can i slove that . I have to create a template in project level
Mark Simpson March 29, 2023, 10:46 p.m.
I had the same problem. After checking all of the above it still did not work. MY FIX: I had my app listed in "Installed Apps" in the settings folder, but it was listed first. The other items have to execute before any apps that are added. I moved my app to the bottom of the list and presto. Thank you for all your input.

Related Articles:
Using IF ELSE condition in Django template
how to use IF ELSE in Django template, Syntax of IF, ELIF and ELSE in Django, Using filters within IF condition in Django template, Multiple elif (else if) confitions in Django template...
How to set a variable in Django template
Declaring a new variable in Django template, Set the value of a variable in Django template, using custom template tag in Django, Defining variables in Django template tag...
How to display flash messages in Django templates
flash messages in Django template, one-time notifications in Django template, messages framework Django, displaying success message in Django, error message display in Django...
5 lesser used Django template tags
rarely used Django template tags, lesser-known Django template tags, 5 awesome Django template tags, Fun with Django template tags,...
DigitalOcean Referral Badge

© 2022-2023 Python Circle   Contact   Sponsor   Archive   Sitemap