My template with called hello.html
<h1>Hello World</h1>
My views.py
from django.shortcuts import render
from django.http import HttpResponse
def say_hello(request):
return render(request,'hello.html')
Also if i try return HttpResponse('Hello World') it is working. But rander is not working.
Make sure you have specifed templates
in settings like below
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / 'templates'],
"APP_DIRS": True,
and make sure you have all also mentioned your app in INSTALLED_APPS
in settings, and also keep you all html files in templates folder
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.