# Exception Type:TemplateDoesNotExist (post/post\_list.html)

**URL:** <https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175>\
**Category:** Forms & APIs\
**Created:** [September 25, 2022, 9:17pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175 "2022-09-25T21:17:33Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![apoorvthedude](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/apoorvthedude/32/10206_2.png) [@apoorvthedude](https://forum.djangoproject.com/u/apoorvthedude)\
**Post date:** [September 25, 2022, 9:17pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/1 "2022-09-25T21:17:33Z")

</div>

Hi folks,  
I’m new to django and following this website ([Chapter 4: Message Board App | Django For Beginners](https://djangoforbeginners.com/message-board/))  
Structure of my file is like :  
main\_prj,SQL,app\_name,manage.py  
app\_name → other files… ,(templates → app\_name-\> HTML file)  
I’ve used ListView template in views.py & error is coming

 ![Screenshot from 2022-09-26 02-45-32](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/6/6f05a459b0c4a25a4308d709e2258ad177aa87cb.png)

I don’t have any post\_list.html file.  
Why this error is coming and how to resolve it.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 25, 2022, 9:48pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/2 "2022-09-25T21:48:56Z")

</div>

This is most likely an error in your view.

Please post the view.

Note: When posting code here, do not post images of code. Copy/paste the code into your reply, surrounded by lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```.

---

<div class="post-metadata">

**Author:** ![apoorvthedude](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/apoorvthedude/32/10206_2.png) [@apoorvthedude](https://forum.djangoproject.com/u/apoorvthedude)\
**Post date:** [September 26, 2022, 6:09am UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/3 "2022-09-26T06:09:06Z")

</div>

Views.py file

```auto
from django.views.generic import ListView
    from .models import Post

class HomePage(ListView):
           model = Post
           template_name = "home.html"

```

templates structure in the app  
App\_name → templates → App\_name → home.html

Why it is creating post\_list.html

home.html

```auto
<h1> Message board homepage </h1>
<ul>
{% for post in post_list %}
<li>{{post.text}}</li>
{%endfor%}
</ul>

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 26, 2022, 11:36am UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/4 "2022-09-26T11:36:00Z")

</div>

First, the reference to `post_list.html` is a reference to the default view name for a ViewList. If it can’t find the view named in the `template_name` attribute of the class, it will try to find that default view. So the root cause here is that it’s not finding your `home.html` template.

Now, note that the tutorial has:

> In your text editor, create a new file called `templates/home.html`

So the tutorial is written to have you put your template directly in the `templates` directory, not within a subdirectory for the app.

You can either change the location of your `home.html` template or change your reference in the `template_name` attribute to match its actual location.

---

<div class="post-metadata">

**Author:** ![apoorvthedude](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/apoorvthedude/32/10206_2.png) [@apoorvthedude](https://forum.djangoproject.com/u/apoorvthedude)\
**Post date:** [September 26, 2022, 3:46pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/5 "2022-09-26T15:46:50Z")

</div>

I have put the path of the home.html in template\_name.  
Ex:  
In views.py file

template\_name = “app\_name/templates/app\_name/home.html”

Still not working.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 26, 2022, 3:50pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/6 "2022-09-26T15:50:20Z")

</div>

What is your TEMPLATES setting in your settings file? (Specifically the DIRS setting)

---

<div class="post-metadata">

**Author:** ![apoorvthedude](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/apoorvthedude/32/10206_2.png) [@apoorvthedude](https://forum.djangoproject.com/u/apoorvthedude)\
**Post date:** [September 26, 2022, 4:00pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/7 "2022-09-26T16:00:19Z")

</div>

```auto
'DIRS' : [BASE_DIR/ "post/templates/post"], # app_name/templates/app_name

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 26, 2022, 7:00pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/8 "2022-09-26T19:00:19Z")

</div>

Just to be explicitly clear, you have written:

> [@apoorvthedude](#):
>
> app\_name → other files… ,(templates → app\_name-\> HTML file)

and:

> [@apoorvthedude](#):
>
> templates structure in the app  
> App\_name → templates → App\_name → home.html

but your DIRS setting is:

> [@apoorvthedude](#):
>
> `'DIRS' : [BASE_DIR/ "post/templates/post"],`

What directory contains your “home.html” file?

---

<div class="post-metadata">

**Author:** ![apoorvthedude](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/apoorvthedude/32/10206_2.png) [@apoorvthedude](https://forum.djangoproject.com/u/apoorvthedude)\
**Post date:** [September 26, 2022, 7:44pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/9 "2022-09-26T19:44:30Z")

</div>

Okay,my bad.  
Actually above two code app\_name I’ve given example.  
App\_name = post

So,home.html is in "post/templates/post " → (home.html)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 26, 2022, 8:13pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/10 "2022-09-26T20:13:26Z")

</div>

Ahh, I think I see it now.

The TEMPLATES DIRS setting is already relative to your project root, it’s not an absolute path. You should not prepend BASE\_DIR on to the DIRS entries.  
(Or to be more precise, it’s generally defined that way. It can be absolute, but then in this case, you’d want to verify that the entry being created is accurate.)

Side note: Additionally, if you’re going to store and use templates in apps, you may also want to set the `APP_DIRS` setting to true. In the “common case”, `DIRS` is set to a project-level `templates` directory while the `APP_DIRS` setting is used to specify that templates could exist in the individual `app_dir/templates` directory.

---

<div class="post-metadata">

**Author:** ![apoorvthedude](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/apoorvthedude/32/10206_2.png) [@apoorvthedude](https://forum.djangoproject.com/u/apoorvthedude)\
**Post date:** [September 27, 2022, 7:33am UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/11 "2022-09-27T07:33:18Z")

</div>

My APP\_DIRS setting is true.  
I mean can u please tell me the syntax, what should I write to remove the post\_list.html error.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 27, 2022, 11:28am UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/12 "2022-09-27T11:28:46Z")

</div>

At this point then, my recommendation for you would be to follow the tutorial _exactly_. Make all settings and file locations the same as what the tutorial defines. Start with something known to be correct, then if you wish to change it, make those changes.

---

<div class="post-metadata">

**Author:** ![apoorvthedude](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/apoorvthedude/32/10206_2.png) [@apoorvthedude](https://forum.djangoproject.com/u/apoorvthedude)\
**Post date:** [September 27, 2022, 2:25pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/13 "2022-09-27T14:25:53Z")

</div>

Still same problem is coming it is searching for post\_list.html.

I’ve changed the templates from app to project.

My Files structure:  
main\_prj,post,templates,sqlite,manage.py

templates structure (templates → home.html)

settings.py

```auto
'DIRS' : [BASE_DIR/ "templates"],

```

Error:

```auto
django.template.exceptions.TemplateDoesNotExist: post/post_list.html

```

What to do now ?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 27, 2022, 2:33pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/14 "2022-09-27T14:33:26Z")

</div>

Please post your urls.py file.

Also, you’re showing a view named `HomePage`. Do you have any other views in that file?

---

<div class="post-metadata">

**Author:** ![apoorvthedude](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/apoorvthedude/32/10206_2.png) [@apoorvthedude](https://forum.djangoproject.com/u/apoorvthedude)\
**Post date:** [September 27, 2022, 3:06pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/15 "2022-09-27T15:06:41Z")

</div>

post (app) [urls.py]

```auto
from django.urls import path
from .views import HomePage

urlpatterns = [
path('',HomePage.as_view(),name = 'home'),
]

```

post [views.py]

```auto
from django.shortcuts import render
from django.views.generic import ListView

from .models import Post

# Create your views here.

class HomePage(ListView):
    model = Post
    template = "home.html"

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 27, 2022, 4:21pm UTC](https://forum.djangoproject.com/t/exception-type-templatedoesnotexist-post-post-list-html/16175/16 "2022-09-27T16:21:12Z")

</div>

> [@apoorvthedude](#):
>
> ` template = "home.html"`

Note: The attribute is [`template_name`](https://docs.djangoproject.com/en/4.1/ref/class-based-views/mixins-simple/#django.views.generic.base.TemplateResponseMixin.template_name), not `template`.
