TemplateDoesNotExist

58 views
Skip to first unread message

yerri swamy

unread,
Sep 23, 2019, 12:41:56 PM9/23/19
to Django users
Hi guys,
     
        By using templates folder i am not getting what i am expecting and i am getting error 'Template Does Not Exist' ,and also defaulty it's not coming templates variable in settings.py file,How do i slove this error please explain me any one.  
IMG_20190923_123912.jpg

Abu Yusuf

unread,
Sep 23, 2019, 1:18:14 PM9/23/19
to django...@googlegroups.com
1. ensure you have a folder templates inside static folder
2. ensure you filled up templates_dir: 'templates'
3. ensure 'base.html' exists inside templates folder

On Mon, Sep 23, 2019 at 6:40 PM yerri swamy <dussaye...@gmail.com> wrote:
Hi guys,
     
        By using templates folder i am not getting what i am expecting and i am getting error 'Template Does Not Exist' ,and also defaulty it's not coming templates variable in settings.py file,How do i slove this error please explain me any one.  

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/208e411a-a8f5-4238-b846-f086826f2ff4%40googlegroups.com.

Desh Deepak

unread,
Sep 23, 2019, 1:23:43 PM9/23/19
to django...@googlegroups.com

oba stephen

unread,
Sep 23, 2019, 2:26:59 PM9/23/19
to django...@googlegroups.com
Try using "./base.html"

I believe this should do it. 

On Mon, Sep 23, 2019, 1:40 PM yerri swamy <dussaye...@gmail.com> wrote:
Hi guys,
     
        By using templates folder i am not getting what i am expecting and i am getting error 'Template Does Not Exist' ,and also defaulty it's not coming templates variable in settings.py file,How do i slove this error please explain me any one.  

--

anilumarane

unread,
Sep 23, 2019, 3:21:15 PM9/23/19
to django...@googlegroups.com
Give the html file current path




Sent from my Samsung Galaxy smartphone.

laya

unread,
Sep 23, 2019, 6:28:49 PM9/23/19
to django...@googlegroups.com

Hi ,

You should config the template settings:

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

 

 

Sent from Mail for Windows 10

--

Tosin Ayoola

unread,
Sep 23, 2019, 6:35:05 PM9/23/19
to django...@googlegroups.com
Can you paste the section of your view code & Hw are you referencing your base.html is it directly in ur templates folder? 

On Sep 23, 2019 13:40, "yerri swamy" <dussaye...@gmail.com> wrote:
Hi guys,
     
        By using templates folder i am not getting what i am expecting and i am getting error 'Template Does Not Exist' ,and also defaulty it's not coming templates variable in settings.py file,How do i slove this error please explain me any one.  

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

Deep Sukhwani

unread,
Sep 24, 2019, 3:33:18 AM9/24/19
to django...@googlegroups.com
Hey Yerri, I was recently going through TDD with Python using Harry Percival's Obey the Testing Goat, this is how I have base.html configured and included in the templates further:

Versions: Django 1.11 / Python 3.6.0

Templates settings set to the default value:
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',
],
},
},
]

INSTALLED_APPS has my app added to the list 

base.html template is in the app directory > templates directory (see image below)

Screenshot 2019-09-24 at 08.57.45.png

In the other templates that need to extend from base.html, I include base.html as follows:
{% extends 'base.html' %}

Full code can be seen at this Github repository: obey-testing-goat-tdd-python

Hope this helps, if not - please reveal more details along the lines called out above and if possible, push your code to a Github repo so someone here could access and try to debug it for you.

--
Regards
Deep L Sukhwani


On Tue, 24 Sep 2019 at 00:04, Tosin Ayoola <tosina...@gmail.com> wrote:
Can you paste the section of your view code & Hw are you referencing your base.html is it directly in ur templates folder? 
On Sep 23, 2019 13:40, "yerri swamy" <dussaye...@gmail.com> wrote:
Hi guys,
     
        By using templates folder i am not getting what i am expecting and i am getting error 'Template Does Not Exist' ,and also defaulty it's not coming templates variable in settings.py file,How do i slove this error please explain me any one.  

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHLKn72RA0QThHM0GLNuPAdm9r46fKExeFsgSKy5sj%2Bk_btHVw%40mail.gmail.com.

Manish Maurya

unread,
Sep 24, 2019, 3:36:03 AM9/24/19
to django...@googlegroups.com
create  a folder name as template in your django project and open your settings.py file  in template in dir write "templates"


yerri swamy

unread,
Sep 25, 2019, 5:18:07 AM9/25/19
to django...@googlegroups.com
views.py.jpg

Desh Deepak

unread,
Sep 25, 2019, 6:04:43 AM9/25/19
to django...@googlegroups.com
Create template folder inside testapp.

Like this:
testapp>template>base.html



yerri swamy

unread,
Oct 3, 2019, 7:19:15 AM10/3/19
to django...@googlegroups.com
I tried like this
testapp>template>base.html
but also its showing same issue please help me anyone..
views.py
  1. from django.shortcuts import render

  2. # Create your views here.
  3. def hello_world(request):
  4. 	
  1. 	return render(request,'testapp/template/base.html',{})

Ehab Al-Qabbani

unread,
Oct 3, 2019, 11:33:16 AM10/3/19
to django...@googlegroups.com
Hi,

Add new folder with the application name under the template folder i.e "testapp/templates/testapp"
And move your template files into new folder,
Then, when you call the template:
If the template in the same place of the view.py (application space) call it without the full path i.e "base.html"

If you want to call it from another application call it with application name prefix i.e "testapp/base.html"

Don't forget to configure settings.py.


Warmest Regards,
Ehab

From: django...@googlegroups.com on behalf of yerri swamy <dussaye...@gmail.com>
Sent: Thursday, October 3, 2019 9:18 AM

To: django...@googlegroups.com
Subject: Re: TemplateDoesNotExist
 

Tosin Ayoola

unread,
Oct 3, 2019, 11:34:11 AM10/3/19
to django...@googlegroups.com
Did you set your template folder correctly in your setting file and in your view are you pointing to the right directory where your .html is located? 

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKMSwL-WqaCjmAvqX23kcWT%2BrCv6b25PjQxq-9AKjPkYNOVm2g%40mail.gmail.com.

saeed albooyeh

unread,
Oct 3, 2019, 4:23:12 PM10/3/19
to Django users
hi
you can see the template-loader postmortem part of the error page that you uploaded
there is a list of paths that django expects to find your templates due to your settings file
in the settings file you can see the TEMPLATES list and find out where you should place your templates
for example if APPS_DIRS is True so django will search for templates in every apps directory alongside other paths
in general it is better to put your templates into a folder named same as your app that is inside another folder named templates in your app dir
for example app_dir/templates/app_name/template.html

Desh Deepak

unread,
Oct 4, 2019, 7:18:05 AM10/4/19
to django...@googlegroups.com


yourapp/urls.py

from django.urls import path

from . import path

urlpatterns =[
           path(' ', views.index, name='index'),
]



views.py 

def index(request):
       return render(request, 'index.html')






To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHLKn72%3D6M%2B2Oqx-oev9TW9zLPbCyHbdzh_djbgLZ5%3DuU-EsNQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages