#100DaysOfWeb in Python Transcripts
Chapter: Days 45-48: Build a simple Django app
Lecture: Django starter and architecture
Login or
purchase this course
to watch this video and the rest of the course contents.
0:02
The Django starter, here's the Django homepage and it gives a nice overview what's awesome about Django, I like to quote at the top.
0:12
Django was invented to meet fast moving newsroom deadlines while satisfying the tough requirements of web developers.
0:20
That's true, although there's quite a bit to it to learn Django to get started. Once you know those basics, it becomes relatively easy
0:29
and fast to build robust apps with clean code and good structure. It's fast, it's fully loaded comes with batteries includes
0:39
just like they say about Python and the Standard Library. It has security builtin, so SQL injection, Clickjacking
0:46
Cross-site Request Forgery, all that stuff is covered. I mean, you don't want to imagine even having to write your own code for those things.
0:54
First of all, you might not even know how to second of all, that's the stuff you don't want to worry about.
0:59
You want to build your awesome app. It's scalable which is important, because you're awesome app gets popular you need to handle more traffic.
1:08
Scalable also see in terms of the structure of Django Django has a project and inside it has apps for example, for the code challenge 52, the other day
1:18
I made an app in one Django project and I could easily move it over to another Django project which is great. A little bit on Django's architecture.
1:29
This might seem complex, and at first sight it is. But as we start building our Quotes app, this will start
1:35
to make a lot of sense and basically comes down to a client or web browser, making a request to the web server where our Django app runs.
1:44
The Django project has one or more apps and every app has a URL router that routes the request into the view. The view then has one or more functions
1:55
or classes that handles the request which commonly interacts with the database or Django's ORM and then sends a response back
2:03
to the browser, which includes the template and the data that was retrieved from the database. That's basically all there is to it.
2:11
But again, we will see this in more detail later. With this design, Django follows the MVT design better closer to rated MVC, Model-View-Controller
2:22
or in Django's case, MVT, Model-View-Template. Lastly, how does this differ from other frameworks like
2:30
Flask? As you see here, Django comes with batteries included. Django has its own ORM, it's templating engine. You get it all out of the box.
2:39
Flask on the other hand is bare bones you can't get a hello world at working with seven lines of code.
2:46
But then for templates and databases, you're on your own which gives of course, great flexibility you can use the ORM of your choice
2:54
as well as the template engine. Django forces you to do it the Django way. Its own ORM and templating, which I like.
3:02
But some people say I don't really like that. So I take Flask and build my own or use the components of my choice.
3:08
Flask in that sense is called a micro-framework. It's easier to get started with but when you need to grow to more complex applications
3:15
you have to rely on plugins and more customized design. Django might have a steeper learning curve because as you see here on the diagram
3:23
there's a lot of moving pieces. But once you get that down, you can do it all in Django and you should be fully covered. I hope that gives you an idea
3:31
of how Djangos architecture works. But of course we have a lot more explaining to do and by building a Quotes app
3:37
you're going to see these pieces one by one. So let's see next what we are going to build.