Template does'not exist?

53 views
Skip to first unread message

Mayur Bagul

unread,
Apr 16, 2019, 1:42:08 AM4/16/19
to Django users
Hello community,

i have write one view and tried to render template for that view but it doesnt working and giving error template does not exits?
i tried to solve this error but im not getting where im getting wrong so plz help me with this.

homepage/templates/homepage/index.html/

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <title>Hello, world!</title>
  </head>
  <body>
    <h1>Hello, world!</h1>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  </body>
</html>


Output :   output file is attached to this post.


vies.py :


from django.http import HttpResponse
from django.template import loader


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
















template.PNG

Test Bot

unread,
Apr 16, 2019, 3:07:02 AM4/16/19
to django...@googlegroups.com
Have you registered your application in the settings.py?

--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/95e12c57-e3c8-4b9d-8ed7-503a5c9401d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Soumen Khatua

unread,
Apr 16, 2019, 3:10:51 AM4/16/19
to django...@googlegroups.com
Hi buddy,
Please follow this convention hope it will works for you.
Happy to help.

views.py

from django.shortcuts import render

urls.py

from django.conf.urls import url
from yourappname inport views

url(r'^$', views.index)


Soumen Khatua

unread,
Apr 16, 2019, 3:11:17 AM4/16/19
to django...@googlegroups.com
Yes man, i lareday did that.

SuryaKumar K

unread,
Apr 16, 2019, 3:19:00 AM4/16/19
to django...@googlegroups.com
Hi, 
It's will occur only if we not given proper template url. You can fix this by the following
check with settings.py 
template dictionary value must hold the exact templates directory location (Try to solve using # os.path(basedir, 'templates') #)
you have to add your app to installed app



For more options, visit https://groups.google.com/d/optout.


--
Suryakumar K
Application Developer
No.12 A, Kamak Towers, Guindy, Chennai - 600032, India.
+91 8220772825   suryakumar1024

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please delete it right away or notify the sender.

naimur rahman

unread,
Apr 16, 2019, 3:30:36 AM4/16/19
to django...@googlegroups.com
django.shortcuts import render

import this in your views.py file

Mayur Bagul

unread,
Apr 16, 2019, 3:54:43 AM4/16/19
to Django users
hello Soumen,

thannks for help. actually before adding template i run my app and it was working fine. 
as you mentioned i took care of imports url but after adding templates it showing error template doesn't found . 

thanking you.


On Tuesday, April 16, 2019 at 12:40:51 PM UTC+5:30, Soumen Khatua wrote:
Hi buddy,
Please follow this convention hope it will works for you.
Happy to help.

views.py

from django.shortcuts import render

urls.py

from django.conf.urls import url
from yourappname inport views

url(r'^$', views.index)


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

Mayur Bagul

unread,
Apr 16, 2019, 4:09:25 AM4/16/19
to Django users
hi surykumar,

thanks for valuable help. actually i forgot to register my app.

thanks a lot.



On Tuesday, April 16, 2019 at 12:49:00 PM UTC+5:30, SuryaKumar K wrote:
Hi, 
It's will occur only if we not given proper template url. You can fix this by the following
check with settings.py 
template dictionary value must hold the exact templates directory location (Try to solve using # os.path(basedir, 'templates') #)
you have to add your app to installed app


On Tue, Apr 16, 2019 at 12:41 PM Soumen Khatua <soumenk...@gmail.com> wrote:
Yes man, i lareday did that.

On Tue, Apr 16, 2019 at 12:36 PM Test Bot <online...@gmail.com> wrote:
Have you registered your application in the settings.py?

To unsubscribe from this group and stop receiving emails from it, send an email to django...@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...@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...@googlegroups.com.


--
Suryakumar K
Application Developer
No.12 A, Kamak Towers, Guindy, Chennai - 600032, India.
+91 8220772825   suryakumar1024

Mayur Bagul

unread,
Apr 16, 2019, 4:12:16 AM4/16/19
to Django users
hi onlineJudge,

thanks for your valuable help. your guess was right i forgot to add my app to project.
now i'm able to run my template.
but i have one question that even without registering my app i was getting desire output from created views at that time it didnt gave me error.

thanks a lot.

On Tuesday, April 16, 2019 at 12:37:02 PM UTC+5:30, OnlineJudge95 wrote:
Have you registered your application in the settings.py?

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

Mayur Bagul

unread,
Apr 16, 2019, 4:14:20 AM4/16/19
to Django users
Hello Community,

Thanking you all for helping me to get rid of this impedance.

i got solution from your answers thanks to you.

Test Bot

unread,
Apr 16, 2019, 11:18:07 AM4/16/19
to django...@googlegroups.com
Do you mean you were able to use templating without registering your app?

You can view basic HTTPResponse objects but I think you can't use templates without listing your app, reason being django looks for templates folder inside each listed app according to the docs. I am open to correction if any.

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

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages