Qiita is very useful, but sometimes writing the code as posted doesn't work. I tried to write the code referring to the article below, but an error occurred.
If you know Python, you can make a web application with Django https://qiita.com/Taro_man/items/19613663ef7bb3c57d4f
An error occurred when trying to connect to the completed site as shown at the bottom of the article.
As I said earlier, the article was very useful.
I will post it as a memorandum when I stumble, although it is a turning point unique to beginners.
The error was resolved by changing the name of the folder where the html file is saved. Error: template No error: templates
By the way, my environment is as follows. Windows10 64bit version 2004 Python 3.8.6 Django 3.1.4
I don't think that error = mistake. I think there are various factors, so I hope you can take this as an example of an error.
The first thing I noticed is here! 【Exception Type: TemplateDoesNotExist】 The content is "I can't find the template".
① Register your application in INSTALLED_APPS in ./my_project/settings.py The majority of them are this error when examined. However, there is no problem with the description.
② Description of ./my_project/urls.py In the official tutorial, I missed the description to import include and got an error. There seems to be no problem this time.
③ Description of ./sample_app/urls.py There is also a description of importing views, and there seems to be no problem with the description of calling views from the received URL. By the way, is it the contents of views?
④ Description of ./sample_app/views.py Call the function from the received URL and return it with return. Hmmm, simple ... Why is it so? I don't know.
⑤ Description of ./sample_app/template/sample_app/post_list.html Isn't html strange in the first place? → It looks normal when opened. Going back to the beginning, what is the file name? → Not wrong.
⑥ Isn't the environment of the article different from my environment? Try the Django Girls tutorial in the same environment. → Doesn't it work without problems?
⑦ Visual Studio Code (VS Code) code check! I'm getting a great error when installing flake8. → I just checked the format of pep8.
⑧ Compare it with the Django Girls tutorial. Compare ① to ⑤, but there is no problem. ... but it feels strange. Isn't Django Girls' html save destination set to templates? here! ?? such a thing! ?? I wonder if it depends on the version. ・ ・ ・ ・ ・ ・ If you change the folder name of the article with half confidence, it will work.
that's all
In fact, I still don't know where in the error content I was able to troubleshoot most efficiently.
・ By checking the behavior of Django while following the code, I was able to better understand the mechanism of the application. ・ Information on the Internet is moderate. ・ If you do the tutorial while thinking about the meaning, you will somehow understand the contents that you could not understand until now.
And a refreshing feeling when this trouble is solved!