[PYTHON] To myself as a Django beginner (2) --What is MTV?

** Tutorial list **

No. title
1 To myself as a Django beginner (1)-Project app-
2 To myself as a Django beginner (2)-What is MTV-
3 To myself as a Django beginner (3)-Hello world!-
4 To myself as a Django beginner (4)-Memo app creation-

** Last review **

Last time is ready. Let's write the code this time! Before, let's take a quick look at how Django works.

** Let's Django -What is MTV-**

In the first place, * Django consists of three main roles, Model --Template --View, and these acronyms are called MTV model or MTV framework. *

--Model: Describes the definition of the data to be stored in the database and retrieves the data from the database. (Models.py) --Template: The design of the page designed by the template file (HTML). (Templates) --View: Gets data from the database on request and decides how to display it on the screen. (Views.py)

......??

It's hard to imagine even if you read this much. What to hide A month ago I had a lot of trouble understanding this. A simple diagram is shown below, so let's look at it together. django_flow.PNG

Let's look at the figure.

Rough flow

  1. You (the client) go to https://www.japanese-django.com/about. (Http request)
  2. In ʻurls.py`, decide which ** View (returnAboutPage ()) ** to process according to the URL (** / about **) requested by you, and request the process. I will.
  3. The requested ** returnAboutPage () ** retrieves data about ** About ** defined in models.py from the database. Put those data on the appropriate ** Template (about.html) ** and display it on the screen. (response)

After going through these steps, you were finally able to see the contents of https://www.japanese-django.com/about. It's okay if you haven't come to a pin yet. Suddenly, on the day when I was actually writing the code, I suddenly said, "Ahhhhhhhhhhhhhhhhhhh!

** Summary **

Django uses the ** MTV model **.

--Model: Definition of data to be stored in the database and acquisition of data. (Models.py) --Template: Page design with template file (HTML). (Templates) --View: Processing according to the request (how to display on the screen). (Views.py)

Next time will be doing "Hello World!" With Django!

** References **

Recommended Posts

To myself as a Django beginner (2) --What is MTV?
To myself as a Django beginner (3)-Hello world! ---
To myself as a Django beginner (1) --Create a project app--
To myself as a Django beginner (4) --Create a memo app--
What is a dog? Django installation volume
What is a dog? Challenge Django templates! Volume
What is a distribution?
What is a terminal?
What is a hacker?
What is a pointer?
I tried to explain what a Python generator is for as easily as possible.
What is a dog? Django App Creation Start Volume--startapp
What is a dog? Django App Creation Start Volume--startproject
What is a decision tree?
What is a Context Switch?
What is a super user?
What is a system call
[Definition] What is a framework?
What is a python map?
[Python] What is a zip function?
[Python] What is a with statement?
Steps to create a Django project
What is a lexical scope / dynamic scope?
What is a Convolutional Neural Network?
[Mac OS] What to do when Python is not installed as a framework. Is displayed when import matplotlib is performed.
[Python] What is a formal argument? How to set the initial value
[Introduction to Python] What is the difference between a list and a tuple?
Migration from Python2 to Python3 (Python2 is rebuilt as a virtual environment and coexists)
order_by ('-created_at') ← What is "ー"? ?? ?? [Beginner learns python with a reference book]
What is a C language library? What is the information that is open to the public?
What is the fastest way to create a reverse dictionary in python?
Django TemplateDoesNotExist at / is out! (Simple but addicted to half a day!)
What to do when a warning message is displayed in pip list
[Pandas] What is set_option [How to use]
What is a dog? Python installation volume
What to do if Django can't load an image from a static folder
[Python] What to check when you get a Unicode Decode Error in Django
[What is an algorithm? Introduction to Search Algorithm] ~ Python ~
What is a dog? Django--Create a custom user model
How to disguise a ZIP file as a PNG file
How to develop a cart app with Django
I'm addicted to Kintone as a data store
Django REST framework A little useful to know.
It's a Mac. What is the Linux command Linux?
(Linux beginner) What is the magic word aux?
How to create a Rest Api in Django
[Introduction to Udemy Python 3 + Application] 54. What is Docstrings?
What is a dog? Django--Create a custom user model 2
Tell me what a conformal map is, Python!
I want to upload a Django app to heroku
Python's itertools is a little useful to know
What you can understand because you are a beginner How to create a file (first post)
[Introduction to Python] What is the recommended way to install pip, a package management system?
I made a command to wait for Django to start until the DB is ready