I am getting a template does not exist error

For some reason Django is saying my template does not exist. Yet I clearly have an .html folder template. It must not be recognizing it? Can anyone advise me?


from django.shortcuts import render
from django.urls import path 

from django.http import HttpResponse
# Create your views here.

def finance(request):
    return HttpResponse('Here are our business results')

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

def ingredients(request):
    return HttpResponse('Here is the ingredients page')

def menu(request):
    return HttpResponse('Here is the menu page!')

def purchases(request):
    return HttpResponse('Here is where you can find the order history!')


from django.contrib import admin
from django.urls import path, include
from inventory.views import finance, home, ingredients, menu, purchases
from inventory import views
from django.views.generic.base import TemplateView
from django.http import HttpResponse

urlpatterns = [
    path('', views.home, name='default'), # users don't need to see the rocket page anyway. they need to see the home page.
    path('admin/', admin.site.urls),
    path('finance/', finance, name='finance'),
    path('home/', home, name='home'), #I am attempting to connect the home_view function with the views function.
    path('ingredients/', ingredients, name='ingredients'),
    path('menu/', menu, name='menu'),
    path('purchases/', purchases, name='purchases'),



Look at the list of directories being searched for template files. Is that file in one of those directories?

in what file should I be searching for this information? settings.py in the templates? I am sorry I am new to Django

I’m referring to the error message you posted previously. At the bottom of that error page, it’s telling you what directories it’s searching for templates.

1 Like

As your templates file structure refers, Change


def home(request):
    return render(request,'inventory/home.html')

Or put the (home.html) directly under the main templates file

| templates/home.html
| manage.py
1 Like

Thank you so much Ken I can continue working past my error! :slight_smile:

thank you cehceh! So basically I need to go into my views.py and for the parameter after request for my function view I needed to change the path name from home.html to

here is my question though based on this edit I needed to tell it to look in the app folder inventory to see it.

That depends upon where you’re planning to put your templates. The specific answers depend upon how you have your TEMPLATES setting configured for your project along with how you decide to manage the location of those templates.

I also suggest you review the text and examples at Writing your first Django app, part 3 | Django documentation | Django. You probably also want to read How to override templates | Django documentation | Django

1 Like