Template Does Not Exist

46 views
Skip to first unread message

Naty Mina

unread,
Aug 19, 2019, 6:47:15 AM8/19/19
to Django users
,hi guys
finally i could run my project but when i'm trying to open the home page that built i get error template does not exist 
and when i look at the details i see that django.engine looked for the template when it''s not in.
the html file is in the same directory as the views and that's when i want django to look for it.
i need your help to fix that 
please
i attached files so you can see
THANK YOU
Capture.PNG
urls.py
views.py
index.html
urls.py

RONAK JAIN

unread,
Aug 19, 2019, 7:00:31 AM8/19/19
to django...@googlegroups.com
Hey 

can you remove learning_logs in views.py?

please simply write inside view.py :


return render(request, 'index.html')

Maybe it will work for you.

Thanks




--
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/b1d04ad5-f3aa-454e-ba3f-8983c9201920%40googlegroups.com.

naty...@gmail.com

unread,
Aug 19, 2019, 7:02:59 AM8/19/19
to django...@googlegroups.com
no it did not work

Sent from Windows Mail

Bhoopesh sisoudiya

unread,
Aug 19, 2019, 8:04:15 AM8/19/19
to django...@googlegroups.com
Hey 
     Please put index.html file inside template folder and set "template" folder  DIR in setting.py file.

Bhoopesh sisoudiya

unread,
Aug 19, 2019, 8:09:39 AM8/19/19
to django...@googlegroups.com
See in attachment 
IMG_20190819_173534.jpg

naty...@gmail.com

unread,
Aug 19, 2019, 8:17:53 AM8/19/19
to django...@googlegroups.com
yes, I did so and it worked
BTW I didn’t change any settings and it still worked.
but is there no way to set django to look for not just in templates folders? but the directory I want?
i’d like to know
thank you

Tosin Ayoola

unread,
Aug 20, 2019, 4:07:46 AM8/20/19
to django...@googlegroups.com
D problem is either in ur settings.py file u didn't properly set ur template dir correctly (which u can do as follows in ur settings.py In the template setting section,  set d value of ur  DIR =[os.path.join(BASE_DIR, 'templates'] den create a templates folder either in ur app dir or project dir,  in the templates folder  📁 create another  folder 📁 with the name of your app,  then inside that folder create ur html file)  and make sure in your view u reference the html file as eg return render(request, 'app_name/index.html',  {'value_to_display_in_html_file': value_to_display_in_html_file}), that way 

--
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.

Naty Mina

unread,
Aug 20, 2019, 11:36:59 AM8/20/19
to Django users
Thank U


בתאריך יום שלישי, 20 באוגוסט 2019 בשעה 11:07:46 UTC+3, מאת Tosin Ayoola:
D problem is either in ur settings.py file u didn't properly set ur template dir correctly (which u can do as follows in ur settings.py In the template setting section,  set d value of ur  DIR =[os.path.join(BASE_DIR, 'templates'] den create a templates folder either in ur app dir or project dir,  in the templates folder  📁 create another  folder 📁 with the name of your app,  then inside that folder create ur html file)  and make sure in your view u reference the html file as eg return render(request, 'app_name/index.html',  {'value_to_display_in_html_file': value_to_display_in_html_file}), that way 
On Aug 19, 2019 11:47, "Naty Mina" <naty...@gmail.com> wrote:
,hi guys
finally i could run my project but when i'm trying to open the home page that built i get error template does not exist 
and when i look at the details i see that django.engine looked for the template when it''s not in.
the html file is in the same directory as the views and that's when i want django to look for it.
i need your help to fix that 
please
i attached files so you can see
THANK YOU

--
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.
Reply all
Reply to author
Forward
0 new messages