I will also talk a little bit about how everything is connected, what happens when you go to a page and similar.
What is Django?
Django is a framework based on Python for building web sites and web applications. Django is insanely fast, takes security seriously and it's easy to scale. Python is very beginner friendly, and since Django is based on this, it makes Django easy to get started with as well.
Django Project vs Django Apps
It can be a little bit confusing in the beginning, because there are a lot of terms and words you might not have heard about before. Your whole web site is a Django project. And the Django project is a collection of apps.
For example my website codewithstein.com is a Django project. And the project has multiple apps like blog, course and similar. A Django app usually consist of some models, templates and views. I will go into each of these a little bit more in detail.
What happens when you go to a page
Let's you go to codewithstein.com/an-article-example/
First, the web server will get a request which will be "passed on" to Django.
Then the "manage.py" file will be triggered. Very little happens here, it just initialize the environment and select which settings file to use.
The settings file contains information on which urls file to use.
And in the urls.py file, things starts to happen. The url file contains a list of the pages like the front page, about, category, post detail and similar.
Django will now find the correct page based on information from the url.
"an-article-example/" will not match this:
path('about/', views.about, name='about')
But it will match on this:
What happens here is that Django knows that we expect a dynamic address here called slug. When this matches, it will call a view called "post_detail".
So in a few words, the flow will be:
Browser -> Web server -> manage.py -> settings.py -> urls.py -> views.py -> template.html -> the results