[0:00] In today's video, I'll tell you which framework you have to choose between 'Flask' , 'Django' & 'FastAPI' for your next project. [0:08] Does it depend on what kind of project you guys are working on? [0:11] Or does it depend on whether you guys are making any project, then you have to use a given framework for it? [0:15] "How to select a framework?" I'll tell you in today's video by comparing all three of them. [0:21] What options do we have in 'Django'' that we don't get in 'Flask' or 'FastAPI'? [0:25] Let me tell you from the starting. [0:27] Firstly we'll talk about 'Flask', [0:29] 'Flask' is a micro-web framework. [0:31] Which means it is quite minimalistic. [0:33] If you have to do anything in it, everything is not built-in, into it [0:36] It does not have ORM support. [0:38] What does ORM mean? Object Relation Model. [0:40] It means that you won't get native Python code to query the database. [0:45] You won't get wrappers in 'Flask' as you get in 'Django'. [0:49] I'll discuss about 'Django' in a short while. [0:50] But I'd like to tell you that 'Flask' is very minimalistic. [0:54] If you want almost full control on your app, Or you want to make your app lightweight, [1:03] Then you can use 'flask'. [1:05] Now you'll say "What's for me if my app is light weight or not and all?" [1:09] When you work on a project in which you want a lot of control, [1:14] You want to have every bell & whistle in your control [1:18] "I can change it" , "Or I can over-write a particular function whenever I want", [1:24] And let us say if you're connecting to a database, but you want to use another database instead of that. [1:31] Basically you need granular control. [1:33] So you look for a minimalistic framework, Which is 'Flask'. [1:36] Secondly, you don't want unnecessary overheads. [1:39] For eg. There may be some things working behind the scenes in 'Django' that you don't need, [1:45] You have installed a package, which you will definitely use if you are using 'Django'. [1:50] Which you're not using in actual, [1:51] That means you have a code which you are not even using. [1:55] But in 'Flask' this gets minimized. [1:57] You don't keep the code in your source-code directory which you don't need. [2:02] 'Flask' is quite lightweight & minimalistic, I'd rather say it's very easy to learn. [2:08] In 'Django' you have to make efforts to understand things. [2:10] In 'FastAPI' you have to understand the concept, [2:13] 'Flask' & 'FastAPI' are a little bit similar. [2:17] 'Django' is a different framework. [2:19] If asked, which is more similar to 'FastAPI' - 'Flask' or 'Django'? [2:22] I'll say 'Flask'. [2:24] Now let's talk about 'Django'. [2:26] When do you have to use 'Django'? [2:27] You have to use 'Django' when you need a built-in dashboard, Because there's a built-in admin dashboard in 'Django' [2:32] Along with that you have to use 'Django' for major projects. [2:36] If you want a framework in which you get batteries included, [2:40] In which you want ORM, which means you're not writing a lot of complex queries to connect to a database. [2:46] You want to get functionality for built-in search. Which means you get native code in Python. [2:52] Which will connect to your database, [2:54] And along with that you want a lot of things already done. [2:58] I'd like to talk about one more thing, If you want your app to be re-used again & again. [3:04] Suppose you created a blog in your e-commerce website. [3:08] And you want the same blog to plug-in, in your personal portfolio project [3:13] So this can be done very easily from 'Django'. [3:16] And if you're using ORM then you automatically get a lot of functions in 'Django' [3:21] For eg. Suppose you want to fetch all of the users from a given model, [3:29] In that if you write code for ORM then you automatically get suggestions for that. [3:33] In that case I use IDE like PyCharm [3:36] I've done all the development, related to 'Flask' & 'Django' in PyCharm from the very starting [3:41] Because that make things easier [3:43] So in my opinion there's a big role of IDE if you're working on a major project [3:47] If you're using 'Django' then I'll recommend you to use a good IDE [3:52] For eg. "JetBrains PyCharm" [3:54] There are a lot of good features in 'JetBrains PyCharm' I'm using it for quite a lot of time [3:58] In-fact I made my first Python course using JetBrains PyCharm [4:02] And it gives a very good experience because it has built-in functionality. [4:06] For eg. Suppose you're calling a module. [4:08] It automatically figures out what properties and functions does that module have, and starts giving you recommendations. [4:15] Along with that if you're opening multiple files then you get quite a smooth navigation [4:20] And if you're working on a major project then IDEs like this are recommended [4:24] If you want to download "JetBrains PyCharm" I'll give you a link in the description [4:28] And you'll get a link for community version which is absolutely free and you can install it for free [4:35] If you're a student then professional version is absolutely free for you [4:39] I'll add a link in the description for that and other details, [4:42] Another big advantage of using 'Django' is, when you are on a team-work [4:46] Suppose you want to embed a blog or an e-commerce store in your application [4:50] And along with that you want to embed an application for customer support [4:54] So different developers can work on these three applications. [4:58] Then in the end, these can then be merged into a particular 'Django' app [5:02] However you can do that in 'Flask' & 'FastAPI' too, But you have to face a lot of difficulties [5:06] Because I've done these type of projects personally [5:10] I'll choose 'Django' if I have to divide the work between my colleagues [5:15] Specifically if I have to divide apps based on work I'll give an app to each developer [5:20] In that case it'll be easy for me to monitor and merge them all into a master app [5:28] This 'Master App' is called 'Project' in 'Django'. [5:31] In 'Django' you have a lot of commands. [5:33] For eg. Start Project, Create App & Create Super User [5:37] You can do these type of things from 'Django' [5:40] You just have to write command in terminal and you can use [5:44] code of 'Django' which generates automatically when you create a new project [5:49] For eg. If you want to create a super user then you can create a super user [5:52] Or if you want to delete a super user then you can do that too [5:56] If you want to create a new app then you can do that too [5:58] You can add multiple apps in a single project [6:00] If you want to create a big project then I'll suggest you to use 'Django' [6:04] Otherwise I'll suggest you 'Flask' & 'FastAPI' [6:06] Now if I talk about the drawbacks of using 'Django' Then it'll take time for you to learn it [6:11] It'll take time for you to understand things [6:13] When you'll install 'Django' with 'pip' then you'll think it's similar to normal Python Module [6:17] Honestly, it's similar to normal Python Module but it's behaviour is a little bit different [6:23] Because once, 'Django' installs, then you create a new project using Django Utility, [6:29] Then you create a lot of apps in that, [6:31] Then "How to do it's URL parsing?", [6:36] "How to create a URL for it?" and all. [6:38] Suppose I created a Blog, then how can I display a Blog-post using "/blog" or "/slug"? [6:45] If you're a Django beginner, neither Python beginner nor Programming beginner [6:50] But a Django beginner and you haven't ever used Django [6:52] Then it'll take time for you to understand it. [6:57] You can start using 'Flask' & 'FastAPI' in fractions of seconds if you know Python. [7:03] But in Django it'll take some time for you to understand it [7:06] So yes! It's a little time taking [7:07] But there are a lot of in-built features in Django, which is good, if you use them. [7:13] But it's bad if you're creating a basic minimal app, you've installed ORM and you've created apps, [7:22] And you're doing model migration [7:25] You're doing all these when there's minimal use case of your app's database [7:30] And if you use Django in that so in my opinion it's an overhead [7:33] Now, 'FastAPI' relatively is a new framework [7:35] Earlier there used to be wars between Django & Flask, which one should we use [7:39] Not wars but confusions, "Which one should we use?" [7:44] But after the launch of FastAPI, I recommend FastAPI to those who are working on a serious project [7:50] And if you're a Python expert and you know how async IO works in Python [7:54] You know how to work with Types in Python [7:57] Then you can use FastAPI [7:58] But I'm telling you again if you start with 'Flask' , then it'll be easy for you. [8:04] From learning stand point 'Flask' is quite minimalistic [8:06] But if you want performance and you want to use modern features in your web app, [8:14] Then you can switch to FastAPI. [8:16] Thus if you're creating such an application in which speed plays a very important role. [8:20] Then you'll use FastAPI. [8:22] And if you want your app to be scalable, [8:25] And you want to handle thousands of users at a time, then you can go for FastAPI. [8:32] But if you want to create a minimal prototype, so even today I use 'Flask' for that [8:37] If I have to create a very minimal API, I pick 'Flask' and used jsonify, and my API is ready. [8:43] It works quite simple for me [8:44] Yes it can be done using 'FastAPI'.... [8:46] But I personally feel, with 'Flask' it's faster. [8:53] And maybe this is because, I'm using flask for quite a lot of time and every function is on my finger tips. [8:58] So I'm able to use it quite easily. [9:00] Now if I compare these frameworks once again [9:02] So at a high-level 'Flask' is quite minimalistic & easy to use [9:06] 'Django' is not minimalistic at all, takes up a lot of time, overwhelm the beginners [9:11] Comes with a lot of built-in features. For eg. ORM, [9:13] There are a lot of things which takes time to be understood [9:16] But those things are useful & saves a lot of time. [9:18] You get a built-in admin panel which contains all the things to delete and all, basically those are CRUD operations [9:24] Those things are sometimes useful but yes, it takes time to learn them [9:28] But once you learn, how to built a Django App and how to manage it, then you'll love Django. [9:34] If someone ask you to create a Blog, then you'll use Django. [9:36] If someone ask you to built an e-commerce website, then you'll use Django cause in that you'll get built-in admin panel & ORM. [9:42] It'll be easy for you do queries, but only when you know how to use it. [9:45] But if you don't know how to use it then Django will haunt you. [9:48] If I talk about 'FastAPI', So it's a modern framework. [9:50] You can perform async IO in that. [9:53] And it was designed keeping modern python in mind. [9:56] So this was high-level overview about these 3 frameworks. [9:59] Now if I tell you on the terms of performance, then FastAPI is the best. [10:04] But it's not like 'Django' & 'Flask' are not good in terms of performance. [10:08] Look, somethings are built-in in Django. For eg. CRUD operations. [10:11] If you start to write the logic of CRUD Operations in 'FastAPI' & 'Flask', [10:15] Then there's a chance, as a solo developer you'll make mistake in that. [10:18] And your performance may not be as good as the built-in CRUD Operation in Django. [10:22] I hope you're getting my point. [10:24] Now let's talk about ease-of-use. [10:27] I already told you it's 'Flask' then comes 'FastAPI' and then 'Django'. [10:31] Now there are a lot of third-party packages in Flask, For eg. Flask-SQLAlchemy. [10:34] You can use Flask along with MongoDB. [10:37] There are a lot of things you get as a Python package, which you can use to supplement Flask. [10:43] Same goes for Django, there are a lot of packages which you can install in Django. [10:50] But in Django, as I already told you, the best part is, you can divide the apps among the developer. [10:56] And those apps makes the over all development of complex project faster, by merging into a single project. [11:02] I made an e-commerce website on this channel using Django. [11:05] I chose Django because there are a lot of ins & outs when you create an e-commerce website. [11:10] Then there are a lot of things which you have to do from scratch. [11:14] But here I got a built-in admin panel & a lot of things, so this becomes easy for me. [11:19] I've done a lot of projects using 'Flask'. I've made a Blog using 'Flask'. [11:22] You'll use flask when you don't wanna use someone else's logic and you want to write your own. [11:27] And same goes for FastAPI as well. [11:29] Now let me talk about community support. [11:30] In my opinion 'Flask' have the most community support as well as Django. [11:34] But FastAPI somewhere lacks this. [11:37] Now, who's community support between 'Flask' & 'Django' is best? Then it depends upon the problem. [11:41] I don't have the exact numbers to be honest. [11:43] But their community support is a lot better than FastAPI. [11:47] So it also matters somewhere. [11:48] Because if you get stuck on a problem, then you may face difficulties. [11:53] If you're unable to find a solution for a particular problem, [11:57] You get to know that no one has posted it's solution anywhere and you now have to find it on your own. [12:04] So before using FastAPI you can keep these things in mind. [12:08] That you might face unique problems which no one has solved. [12:12] So I hope you got a high-level overview of 'Flask' , 'Django' & 'FastAPI' [12:17] And you can now create your next project. [12:20] You can choose the best framework for your next project. [12:23] That's it for this video guys. [12:25] Thank you so much guys for watching this video :) [12:27] And I'll see you next time.