Why {% endfor %} gives an error?

The website on django 3, and there is a page:
<!DOCTYPE html>
<html lang="en">
the <head>
 <meta charset="UTF-8">
<title>Title</title>
</head>
the <body>
{% for movie in movie_list %}
 {{ movie.title }}
{% endfor %}
</body>
</html>


In the end, go to the page with this file is this:
spoiler
TemplateDoesNotExist at /
movies/movie_list.html
Request Method: GET
Request URL: 127.0.0.1:8000
Django Version: 3.0
Exception Type: TemplateDoesNotExist
Exception Value:
movies/movie_list.html
Exception Location: C:\Users\admin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\loader.py in get_template, line 19
Python Executable: C:\Users\admin\AppData\Local\Programs\Python\Python38-32\python.exe
Python Version: 3.8.0
Python Path:
['F:\\TS_Net',
'C:\\Users\\admin\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip',
'C:\\Users\\admin\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs',
'C:\\Users\\admin\\AppData\\Local\\Programs\\Python\\Python38-32\\lib',
'C:\\Users\\admin\\AppData\\Local\\Programs\\Python\\Python38-32',
'C:\\Users\\admin\\AppData\\Roaming\\Python\\Python38\\site-packages',
'C:\\Users\\admin\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages',
'C:\\Users\\admin\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\buildozer-1.0.1.dev0-py3.8.egg']
Server time: Fri, 3 Jan 2020 07:52:43 +0000
April 4th 20 at 00:37
1 answer
April 4th 20 at 00:39
Solution
Your template is not available. TemplateDoesNotExist
And how to make it available? - Florencio28 commented on April 4th 20 at 00:42
@Florencio28, well, apparently you have the path to the template file is spelled incorrectly. - Orville_Runolfss commented on April 4th 20 at 00:45
@Orville_Runolfss, or configuration of the template curve. - salvador69 commented on April 4th 20 at 00:48
@Orville_Runolfss, path /movies/movie_list.html
file in - /templates/movies/movie_list.html - Florencio28 commented on April 4th 20 at 00:51
@Orville_Runolfss, show me where and how you invoke the template? - okey_Murray commented on April 4th 20 at 00:54
@okey_Murray, movies/urls.py:
from django.shortcuts import render
from django.views.generic.base import View

from .models import Movie

class MovieViews(View):
 """List of movies"""
 def get(self, recuest):
 movies = Movie.objects.all()
 return render(recuest, "/movies/movie_list.html", {"movie_list": movies})
- Florencio28 commented on April 4th 20 at 00:57
@Florencio28,
1. Remove the beginning slash
2. Why would you use a View class for a list of objects of the same model when there is a special class ListView.

from django.views.generic.list import ListView
from .models import Movie

class MovieList(ListView):
 model = Movie
 template_name = "movies/movie_list.html"
- Annabel commented on April 4th 20 at 01:00
@Annabel, https://www.youtube.com/watch?v=WTXPLwrK398 - Florencio28 commented on April 4th 20 at 01:03
@Florencio28,
1. in the video lesson, and it is shown that the path to the template(template) relative(without the slash), not absolute(with the slashes) as you have.
2. So imagine a lesson, you initially teach "not right." IMHO, the microscope too it is possible to hammer in nails. If only as basic and as "possible", but above I showed you how your job is doing the right thing and out of the box. - Annabel commented on April 4th 20 at 01:06
@Annabel, Now try - Florencio28 commented on April 4th 20 at 01:09
And that movie/urls.py to prescribe? - Florencio28 commented on April 4th 20 at 01:12
@Florencio28, class I was renamed as пеп8 it is desirable to specify correctly. In your case when you inherit from the View class, you called your class MovieViews. But when they begin to inherit from a list class, that is, from the ListView, then it is your class called
НазваниеList or НазваниеListView, which I did, describing it as MovieList.
The file with URLs(paths) is an appeal to class, you will need to rename it there.

Well, if you need to fix the bug in your code on the basis of the lesson, p. 1, remove the beginning slash. My example Express in the head. - Annabel commented on April 4th 20 at 01:15
from django.shortcuts import render
from django.views.generic.base import View

from .models import Movie

class MovieViews(View):
 """List of movies"""
 def get(self, recuest):
 movies = Movie.objects.all()
 return render(recuest, "movies/movie_list.html", {"movie_list": movies})

That's without the slash, nothing has changed, the error persists - Florencio28 commented on April 4th 20 at 01:18
@Florencio28, So past errors with the paths you created in the templates folder, the movies folder, and in it the file movie_list.html. Either you have an error in the naming or attaching template directory project.
Your error tells you "not found template(template)". - Annabel commented on April 4th 20 at 01:21
qiu4vy - Florencio28 commented on April 4th 20 at 01:24
Catrinka project tree - Florencio28 commented on April 4th 20 at 01:27
@Florencio28, then the path is not specified in the setting or you have not restarted Python. Search for or copy a project to new class. You could already change the error on the distance is difficult to guess. What you showed above, was a mistake of Templeton, not the for loop and the error on the lack of template. - Annabel commented on April 4th 20 at 01:30
@Annabel, And that it is necessary to specify in setengah? - Florencio28 commented on April 4th 20 at 01:33
All agreed, specified in the templates settings - Florencio28 commented on April 4th 20 at 01:36
@Florencio28, Get Used To It. Sometimes the error in one symbol, and the "problem" may be searched for half a day. Or even elsewhere. Here and climb up the tree(or down), unwinding the tangle of problems. First we found that the problem is the extra slash, then found the setting. :-) - Annabel commented on April 4th 20 at 01:39

Find more questions by tags Django