Zeddrix Fabian
Zeddrix Fabian

Reputation: 2566

How will I connect my index.html to my views.py?

I tried doing this: enter image description here

from django.http import HttpResponse
from django.shortcuts import render

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

But my page says that TemplateDoesNotExist.

enter image description here

What should I do?

Upvotes: 0

Views: 1509

Answers (3)

Niloct
Niloct

Reputation: 10015

Make a templates\justColor subdirectory template inside your justColor folder and move index.html to there. Then as @Neeraj said you can change render call to render(request, 'justColor/index.html').

(Although you should read this part of the django tutorial which will help you more than any trial-and-error in this subject: https://docs.djangoproject.com/en/3.0/intro/tutorial03/)

Upvotes: 0

Ahmed Rehman
Ahmed Rehman

Reputation: 1

Make sure you have configured urls.py and views.py correctly.

This question is already answered here :Django TemplateDoesNotExist?

Upvotes: 0

Neeraj
Neeraj

Reputation: 783

Create a folder 'justcolor' under templates directory and save index.html in it. change path to 'justcolor/index.html'. return render(request, 'justcolor/index.html')

Upvotes: 1

Related Questions