Добрый день.
Смотрю лекцию CS50's Web Programming with Python and JavaScript.
Конкретно по Django.
Делаю все, как в лекции. Посоветуйте, как решить проблему? У меня создана директория myproject, в которой
del_objects.py manage.py myproject newapp
В newapp:
admin.py migrations models.py.save.1 __pycache__ urls.py
apps.py models.py models.py.save.2 templates.py views.py
__init__.py models.py.save modesl.py.save tests.py
В urls.py:
from django.urls import path
from . import views
urlpatterns=[
path("", views.index)
]
В views.py:
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return render(request,"index.html")
В директории templates.py: index.html
В index.html:
<!DOCTYPE html>
<html>
<head>
<title>Programmers</title>
</head>
<body>
<h1>Programmers</h1>
</body>
</html>
Иду в директорию myproject (в которой newapp)
python3 manage.py runserver
Копирую в браузер 127.0.0.1:8000/
TemplateDoesNotExist at /
index.html
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 2.0
Exception Type: TemplateDoesNotExist
Exception Value:
index.html
Exception Location: /usr/local/lib/python3.4/dist-packages/Django-2.0-py3.4.egg/django/template/loader.py in get_template, line 19
Python Executable: /usr/bin/python3
Python Version: 3.4.3
Python Path:
['/home/hidden/myproject',
'/usr/local/lib/python3.4/dist-packages/Django-2.0-py3.4.egg',
'/usr/lib/python3/dist-packages',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/usr/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4/dist-packages']
Server time: Sat, 21 Jul 2018 10:50:40 +0000
Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/dist-packages/Django-2.0-py3.4.egg/django/contrib/admin/templates/index.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/dist-packages/Django-2.0-py3.4.egg/django/contrib/auth/templates/index.html (Source does not exist)