So I was going to do a Flask tutorial this week after learning it in a week, but I decided to do a comparison with Flask and Django since I’ve had hands-on-experience with both python web frameworks. The reason is so that I can help you choose which framework to learn as learning a framework can be very time consuming —- but very fun of course!
CAUTION: I only spent a week with Flask whereas I’ve used Django for the past 3 years. Take this with a grain of salt
Similarities
Let’s start with similarities.
1) Flask and Django are both python web frameworks.
They enable you to create web applications using python for backend logic and html and css as front, or whatever front-end framework you’d prefer.
2) Can use ORM or object-relational-mapping.
This basically means, you can use SQLITE, MYSQL, PostgreSQL, and other databases that utilizes ORM.
–Django by default uses ORM.
–Flask does not come with ORM capabilities by default. You need to manually add it if you want.
3) Templating.
–Django uses a template engine similar to Jinja (actually Jinja was inspired by Django’s own templating system)
Small comment: Django doesn’t use Jinja, but it’s own templating engine. They look similar because, as Jinja’s website says, “It is inspired by Django’s templating system.”
–Flask uses Jinja as its template engine.
Jinja is basically like python for html (python + html = Jinja) that enables you to add logic to your html such us if/else, for-loops, and extension of templates which I really really love!
There are many more similarities between Flask and Django, but for me those are three the main ones.
Differences
The differences are quite big when you put Flask and Django side by side.
With Flask you get incredible flexibility.
You create the app.py (which is like the main logic for your app), the models.py (which is where you store your models that creates the tables for your database), the templating and etc. You have ABSOLUTE control on how you want to build the structure for you app.
With Django, it’s all built for you!
The settings.py (which is like the config file for your app) the models.py, the urls.py (which is where all the routings are stored), the templating, etc.
Which is why Django’s tag is, “The web framework for perfectionist with a deadline.” Because everything is built in, you don’t need to bother yourself with creating the files and thinking about how you should structure your app. It’s all ready for you and you can immediately get started with building your app.
Conclusion
Flask and Django both have their strengths and weaknesses.
Each one has their own uses and purposes.
If you’re making an app that’s simple that doesn’t anything too complex, then Flask is the way to go.
But if you’re a beginner and want to get into web development with python, I’d suggest you start with Flask. The things you learn in Flask can be applied to Django. It’s just easier with Flask.
Congratulations ! You made it! I hoped it helped you out!
Also, tell me if you’d like to see me do
a tutorial of Flask or Django on Youtube.
Thanks ya’ll! Have a break, take a kitkat .
Thanks for all those who gave their feedback and added stuff to my knowledge on Flask and Django! Keep ’em coming
Follow me on Twitter and Instagram @heyimprax.
Subscribe to my channel in Coding Prax.
原文链接:Flask vs. Django?
暂无评论内容