[PYTHON] What I did when I stumbled on a Django tutorial

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. スクリーンショット (1).png

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.

First conclusion

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.

So what i did

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.

Acquired skills

・ 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!

I'm sorry!

Recommended Posts

What I did when I stumbled on a Django tutorial
What I stumbled upon when using CodeIgniter on a Linux server
What I did with a Python array
What I found by deploying Django on EC2
What I did when updating from Python 2.6 to 2.7
I did a little research on the class
What I did when I stumbled upon mounting on MyDrive and loading an ipynb file in Google Colaboratory
A memo that I stumbled upon when doing a quote RT on Twitter Bot
I got a UnicodeDecodeError when pip install on ubuntu
A memo when Django was released on VPS (preparation)
Where I stumbled on SQLite3
A story that stumbled when I made a chatbot with Transformer
A solution when you can't start project Django on Windows
I stumbled when I tried to install Basemap, so a memorandum
I stumbled on TensorFlow (What is Out of GPU Memory)
A note when I can't open Jupyter Notebook on Windows
A note of what I learned when I thought about using pyenv or virtualenv on Windows
What I did to output application logs on GAE Flexible Environment.
A note on what you did to use Flycheck with Python
H29.2.27 ~ 3.5 Summary of what I did
A note I was addicted to when making a beep on Linux
Implement a Django app on Hy
Stumble when doing the django 1.7 tutorial
What I did when I wanted to make Python faster -Numba edition-
[Django] I wanted to test when POSTing a large file [TDD]
I did a lot of research on how Python is executed
A reminder of what I got stuck when starting Atcoder with python
A memorandum because I stumbled on trying to use MeCab in Python
I get a firewall warning when I start gqlgen's server.go on my Mac
A memorandum when Django is installed on Sakura's rental server (standard plan)
I made a webAPI! Build environment from Django Rest Framework 1 on EC2
Django Crispy Tutorial (Environment Building on Mac)
What I got into when using Tensorflow-gpu
What I referred to when studying tkinter
I stumbled on the Hatena Keyword API
A struggle when installing pyenv on Cygwin
I have a question! (Python, django) Easy
I stumbled upon installing sentencepiece on ubuntu
What is a dog? Django installation volume
I installed Kivy on a Mac environment
[Django] A memo when log was not
What I learned at hackerrank on 1/30 days.
A note on enabling PostgreSQL with Django
I built a TensorFlow environment on windows10
I made a WEB application with Django
What I did to save Python memory
While studying pandas, I did a free study on when corona would end and whether lockdown was meaningful.
What I was addicted to when creating a web application in a windows environment
In the Chainer tutorial, I get an error when importing a package. (mock)
I stumbled on the character code when converting CSV to JSON in Python
What I did when I got stuck in the time limit with lambda python
I tried a TensorFlow tutorial (MNIST for beginners) on Cloud9-Classification of handwritten images-
[Python] What to check when you get a Unicode Decode Error in Django
[Linux] Let's talk about when I stumbled upon a symbolic link I was using.
I referred to it when I got stuck in the django geodjango tutorial (editing)
What to do when matplotlib gets angry on CentOS saying "I'm using Agg so I can't issue a figure"
A memo of a tutorial on running python on heroku
A addictive story when using tensorflow on Android
What is a dog? Challenge Django templates! Volume
When I get a chromedriver error in Selenium
[Python] What I did to do Unit Test