Django makes it easier to build better Web apps more quickly and with less code.
No matter if you’re a beginner or Professional web developer, use Django Python web framework for your web project otherwise you’ll end up building and assembling a Django all together and you will learn that in a hard way.
Well that’s not completely true, if you’re sure that your project will never ever requires things that Django offers all together, then feel free to use something lightweight.
Many developers either beginners or advanced ones, struggle to pick up a right framework to work with. Some like the simplicity of Flask that gives them a lot of freedom so they can choose what so ever they want to.
That’s the problem right there, you have to choose, decide, maintain, glue and assemble tons of libraries to get your project working and keep doing this in as long as your application exists.
In this article I’m going to set Flask as a small lightweight framework against heavy unchained Django and talk through the example by comparing them for the scenario.
Now, creating a Blog in Web Frameworks in like a Hello World program, this is how we compare them most of the time without going into wild details.
Let’s see how to build a Blog application, a Blog web application usually has:
Those are the basic of many kind of web applications.
Web development, one drop at a time
Flask doesn’t have anything to do with your Database, has no idea what a database is, it comes with a nice way of URL routing to your views/controllers and return the HTTP response which can contain a HTML template with Jinja as the engine. That’s it.
The rest of the cycle is on the developer.
Here’s what you need to start a simple Blog web application. The below is a list of things you need to assemble to get up and running:
Again, please note that all the extensions you find in many cases need to work together nicely and you to have assemble them in that way, otherwise bad things might happen and you don’t want to witness such things. Remember, you can use your time to add more features and do other awesome things in your life rather than doing tons of time consuming work that could be handled much efficiently with other tools.
Now, let’s see how we can make this happens with Django.
You only need Django, that’s it, have a nice day.
Yes, move on, nothing left to do.
Both Flask and Django have nice ready made Blog web applications by the community in a very good shape. Django has Zinnia and Flask has Flask-Blogging. (Zinnia is much mature and feature complete.)
In this post I tried to show how one would implement such simple and basic thing.
It’s not about Django vs Flask or which one is the winner. Tools get built for a purpose and in many cases tools don’t wanna replace each other and they shouldn’t be looked at in that way.
Any web framework has its own area of work and capabilities, you as the developer or designer of the system should wisely decide to choose the right tool for the job.
Flask is minimal, you can create big projects with it for sure, but you realy need to glue tons of other tiny applications together, this means more maintenance and work. More work, more work and more work. You have to find the good ones, or solid ones. Each part is developed separately. If any of the part breaks other parts might start bleeding as well. If any of the third party library got abandoned or a certain bug fix is not released, then you have to deal with the issue.
This issue is there if you pick the wrong tool for the job and build bloking blocks upon each other.
Django on other hand has most of the things you need for many kind of web applications and covers them very well.
If your project is a small one page app that doesn’t need much complexity, for sure Flask rocks here. I use Flask when I have tiny and small web application that have only one tiny purpose to serve and done. On the other hand Django is my choice when complexity is higher, database is important, forms are required, admin panel is a must and integrity between my application parts has to be solid as possible. Not only with my application but other third party applications follow the same rule in Django ecosystem.
In many cases Beginners start with micro-frameworks when others have recommended them such thing. Mainly because it’s simple to get starting with or easier to understand the “Quick Start” page of their documentation.
If a beginner wants to build a simple blogging web application, choosing a micro-framework would be a huge mistake due to above reasons that I mentioned. It adds tons of complicated processes for them, confusion after confusion and in many cases people would give up and look somewhere else. They spend a lot of times while gluing things together. Some people like to say this will make them understand more and help them to finf out what’s under the hood and how things work, I don’t think so. It usually makes them get tired and hate the whole thing.
Advanced Developers should find out more what the beginners are trying to build and then suggest them the right tools.
Use the right tool for the job.
Choose Django if:
Go with Flask or any other micro-frameworks if:
Otherwise, you’ll end up building a Django.