TemplateDoesNotExist at /test/ error popped up while running application

I am using Django 3.0.8
My view function is as follows:

from django.shortcuts import render import datetime
# Create your views here. 
def  date_time_view(request):
    date=datetime.datetime.now()
    h=int(date.strftime('%H'))
    if h<12:
        msg='Hello Guest!!! Very good Morning!!!'
    elif h<16:
        msg='Hello Guest!!! Very good Afternoon !!!'
    elif h<21:
        msg='Hello Guest!!! Very good Evening!!!'
    else:
        msg='HELLO GUEST!! very good Night!!!'
    my_dict = {'date':date,'msg':msg}
    return render(request, 'testapp/results.html', my_dict)

and my template is as follows:

<!DOCTYPE html> {%load staticfiles%}
<html lang="en" dir="ltr">
<head>
    <meta charset="utf-8">
    <title>hello</title>
</head>
<body>
<h1>{{msg}}</h1>
<h2>{{date}}</h2>
<img src="{%static  " images/images.jpg" %}">
</body>
</html>

Upvotes: 0

Views: 51

Answers (2)

Maciej Rogosz
Maciej Rogosz

Reputation: 92

Check your configuration in your project settings file. Templates can reside in each app separately, but also in a templates folder in APPS_DIR (folder with all Django apps).

Here is official docs for Django 3 templates: https://docs.djangoproject.com/en/3.0/topics/templates/

Upvotes: 1

Talha Quddoos
Talha Quddoos

Reputation: 556

Check your template's location. It should be yourproject/yourapp/templates/testapp.

Upvotes: 0

Related Questions