Flask over Django

I just built my first Flask website and I have to say I'm pretty impressed with the framework and ease of use.

All I kept reading about was that you need to use Django for complex projects, Flask is only suitable for simple websites.

Yet with Flask I've got a fairly extensive app file with multiple API's and supporting Py files for additional API's. Not to mention all of the templates feeding off of these files.

Am I missing something when it comes to Django? When would I really need it over Flask, where would Flask fail?

10 thoughts on “Flask over Django”

  1. I see it like this; with Flask and the right extensions, you can build something like Django. The advantages are that you get to **choose** which parts you include and what type (for example, Django has its own ORM included, with Flask you can choose from several ORMs).
    So Flask is more flexible in that regard. Django has a lot included, but that means you can also get stuff that you don’t want. This can cause overhead or security issues.
    So if you’re building a large project and you want to get started quickly, Django could be helpful. Myself I like the Flask approach, where I slowly build towards the exact stuff I need for my app.

    Reply
  2. I’m annoyed that I have to build an admin dashboard in Flask when I know Django has it built in. End of the world? No. But I generally like batteries included because then I don’t have to buy the batteries.

    Reply
  3. In my job, I basically do consulting for a bunch modern SaaS companies. I see a little of both.

    I can tell you Flask is hardly a “simple website” framework. It’s minimal. It’s very modular with virtually no bloat. It’s excellent for making modern websites and apps because how easy and powerful it is for building APIs. If you want to build a scalable microservice architecture, the frameworks like Flask is where it’s at from what I’ve seen.

    Django is a traditional monolithic framework. It follows the MVC/MVT concepts. I’m not saying you can’t use it to do a modern site with micro services, it’s just not what it was originally made for.

    It’s not dead at all and hardly antiquated, but it’s on its way to the part of its lifecycle like PHP and RoR: still fine, but not modern and usually more of good to know for the established companies. You won’t find many startups creating an architecture today from the ground-up on Django.

    Basically, I’m glad I know Django. It’s excellent for 1-person projects as so much is already done. But there’s a bunch of forcing it to do things it wasn’t design to do originally, and it just feels far more bloated at this point to me. Not to mention, the more complex the framework is originally, the more likely there’ll be hidden and obscure vulnerabilities people don’t know about.

    Flask is exactly what it is and nothing more: basically a minimalist web framework to do exactly what you want with nothing else to get in the way. You will find it used in many ways today. I find it it many guides and architectures for microservice environments (kubernetes and Docker for example).

    I feel that it’s easier to switch off Flask to something else if you need. Migrating off Django can be a headache in my personal experience.

    Basically I think you have it reversed. If you want a simple website that can do a good amount for a 1-person hobby project, Django is probably fine. If you want to have a highly scalable architecture with less lock-in for a complex system, Flask is a better approach. Both can do either with more effort in certain parts the other may excel at, so you need to figure out what your priority is for the project and use the right one.

    Reply
  4. For me, as a django developer, I wish I could have learned flask first. Some concepts are abstracted in django that you wish you know more about it instead of the framework hiding it. I just feel like it affects my growth as a developer, not knowing things. However, Django can really help to make projects to be done faster because it’s batteries included.

    To your question, technical knowledge wise, i think you’re not missing something because the thing you’re doing in flask is just abstracted in django. That’s what flask devs say based on my readings. However, development & productivity wise, you’re missing the features that can make you build things fast because of the django’s ‘batteries-included’ feature.

    Reply
  5. I think people are answering the engineering and development, computer science questions, I would like to attempt to answer the money question.

    The reason why you would want to use a non-opinionated framework such as flask over an opinionated framework such as Django, is because of, “big data,” and, “machine learning,” and the like. Since a non-opinionated framework allows you to literally choose the architecture of the framework, you are figuratively building things from the ground up, and you could use whatever document store or database management system imaginable. Django has a built-in ORM, so you’re limited to that and organizing your data management from that ORM and all of the advantages and limitations included in that ORM.

    Currently I believe there are far more jobs in Django and opinionated web service building, because it’s the thing that’s needed right now, it’s the money that’s being spent, to build a fixed, “web app,” which perhaps, “deploys a machine learning thing,” however as data grows, and as machine learning needs get more complex and customized over the next decade more complex solutions need to be built which are going to manage that growth, and this may mean non-opinionated frameworks, and premiums might be paid for these types of things.

    Typically when I read posts about flask vs. django they claim the other way around, they say, “flask is for beginners.” In my experience, yes, flask can be easy to get going, but once you get past a certain point, it is used to be build extremely complex things, and it’s no longer the realm of beginners, it’s the realm of data architecture, which pays bigger bucks and is used for large systems, such as NLP training and building.

    Reply
  6. I’m a full stack web dev working for a machine learning company.

    I use flask extensively for our services and backends. I’d say the modularity and extensibility can be a bit of a footgun, particularly in the hands of ML engineers who aren’t trained in or used to the web paradigm.

    The trouble is it’s deceptively easy to get started and then easy to accidentally make very complex, or do a lot of synchronous work and block the worker, or make a big security hole.

    Flask makes it easy to do the right thing but also easy to do the wrong thing. It just gets perceived as easy though.

    Django, Rails, and the like have established built in conventions that make it easy to do the right thing but *hard* to do the wrong thing. That makes it harder to learn but better the more complex it gets.

    Reply
  7. Django is a favorite of the bootcamp crowd. It’s easier for newbies to get up and running. With Flask you’re forced to learn how things work.

    Reply
  8. I had been waffling between Flask and Django for some time and played with both just to see how I could build something in both. Eventually, I sided with Flask as I wanted something really lightweight and needed something to quickly migrate away from PHP/silex.

    I’ve now built two websites (with Materialize for front-end), one data reporting site and an API service all using Flask. I found that routes, blueprints and Jinja were dead simple for me to pick up and use where appropriate. Having said that, I’m in the process of migrating the API service over to FastAPI.

    None of the sites have an admin interface and don’t need the ability to insert/update/delete records in the database. If I need to add that functionality, I know there are several options available for Flask.

    Reply
  9. Amazing, thanks for all the comments. What I’m understanding is that many companies have built with Django thinking that they need the framework, but actually Flask can handle complexity (with Blueprints for example) but also be more flexible and lightweight.

    A few people mentioned the possibility of having Flask ‘security holes’ could someone elaborate on this?

    Reply
  10. I prefer flask because ot isn’t opinionated. You can choose your stack. With Django almost everything has been chosen for you, like it or not.

    Reply

Leave a Comment