this is current_datetime.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
it is now {{date time}}
</body>
</html>
this is templates in settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
this is views.py
import datetime
from django.shortcuts import render
def current_datetime(request):
now=datetime.datetime.now()
return render(request,'mysite/template/current_datetime.html',{'datetime':now})
this is urls.py
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('admin/', admin.site.urls,name="admin"),
path('current_datetime/',views.current_datetime,name="current_datetime"),
]
and this is my directory
but when i run server by "python manage.py run server" and go to this url:
http://127.0.0.1:8000/current_datetime/
i got this error:
TemplateDoesNotExist at /current_datetime/