From the course: Introduction to Django
Overview of Django - Django Tutorial
From the course: Introduction to Django
Overview of Django
- Okay, so before we start moving on to like actually building a Django project, let's look at a brief overview of what Django is and why you might want to use it. It labels itself the web framework for perfectionists with deadlines. It is meant so that you can build features fast and there is a lot of security features built-in so that you don't have to worry about all of that if that's not your wheelhouse. It also scales in size well and you can use it for starting out small projects and then build features and it can grow and grow and handles all of that pretty seamlessly. And it's also built in Python, which is a very well-known and beloved language that developers often already know. And, you know, if you want to build an application or a web application in a language you already know, it's a good choice. So it is a web framework written in Python and you will use Python to write all of the backend code. And it's also fully-featured. So there's, as I said before, a bunch of security features. It comes with an admin interface for being able to manage things in the backend of your website. It, you know, has sessions and caching built-in and some user management and permissions already given to you out of the box. And it's used by a ton of big websites and web applications as well as a lot of smaller ones. For example, all of these websites are built in Django. You know, the larger the company, the more like they have lots of different pieces built in different frameworks and technologies. But these ones, a lot of the core pieces are running in Django. Some other web framework alternatives, if you did want to use Python is for some simpler or single page websites, you can consider Flask. It is considered a micro-framework. It is used for larger websites as well, but it only comes with a small subset of the features and you just need to like add on more and more libraries. The more features that you want and the bigger that your code gets and your scope gets. If you're doing just APIs, you know, Django is often used for just building the backend of APIs and connecting it to some sort of react or view front-end. But for pure APIs, you can consider just using the FastAPI framework as well 'cause that's another good one written in Python. And for when you're, the speed that you need to work in or developer resources are tight, or if you just like don't want to learn all of this stuff, you can consider Anvil. It's a really cool tool that's, you can have it all web-based drag and drop interfaces. You don't need to know HTML or CSS or JavaScript and it's all written in Python. So looking a bit about the history of Django, it was started in 2003 by a couple of guys who worked at a newspaper company in Kansas and they built it to create new features really quickly, especially working with other non-technical developers. So like content people and and things like that. It was released as open-source in 2005, and it was named after the jazz guitarist, Django Reinhardt. And it was built to create things fast under deadlines with many non-developers. Like I said earlier. (laughs happily) You can read more about the story of Django in this book, "Django Design Patterns". The architecture of Django, it uses an MVT pattern. So you might be familiar with the MVC pattern, which stands for Model View Controller, but Django use MVT where the models M is for models, which is the same, it interacts with the database via an ORM. Okay? So basically, an ORM will take data in your database tables and turn them into Django objects that you can then work with in a more Pythonic way. The view is different from the MVC view. So the views are what handle HTTP requests and return responses, but it's basically the glue that uses the models and then turns them into templates or like uses them in templates. So the templates is what the view in MVC would be. Yeah, I'm probably going way too much into detail about this 'cause it doesn't really matter that much. But templates allow you to create dynamic HTML pages from Python data and then the views kind of manage your models and templates. Okay, so here's a little diagram about the Django architecture and I will describe it briefly here. It probably won't make more much sense until after you go through lessons two and three. So the first step is that the user is on their computer, browsing the internet, and they send an HTTP request to your Django app. So that gets sent into Django and to the URL configuration and the URL conf is, has a bunch of URL paths and then it decides which view, which should handle that request. And then the view gets a request and then can talk to a database via the models and render an HTML template based on some data that it gets from the models. And then that turns it into an HTTP response and then sends it back to the user so that they can, you know, see a website or continue on or, you know, the user could be an API and it returns JSON. So Django projects are composed of a number of apps and Django also comes with some of its own apps that it uses and such as like for user management and things like that. So when you have a larger Django project, like say I have a newspaper company and I could have one app that's for articles, one app for news and announcements, one app for events and maybe a calendar. And so that's how it's kind of decomposed into different apps and you can then like use one app in this project and then maybe you've got another project that you want to reuse a bunch of it while they're already separated out for you, so that you can easily do that or more easily do that. Okay, o that was our introduction to Django and in the next lesson, we will look at actually starting our Django project.