I feel like Flask is so much better than Django

I know how to use both to make basic web apps, and Flask has just been an overall better experience.

1. Flask is easier to get started with. Make a file, type like 7 lines of code to create a route, and add stuff as you go. In Django, you are overwhelmed by a bunch of files with no explanation to what they do.

2. In Flask, you have control over your app and know what it is doing. Django users claim that giving control to Django saves time, but in my experience it makes things 1000x more confusing than it needs to be. For example in flask, you actually make login cookies and stuff to handle logins. In Django, you pass it to this built-in user model and some black magic happens, then you have to keep googling how to change placeholder text and what forms show up.

3. Handling forms in Django is atrocious imo. Which would you rather do?: Type like 4 lines of HTML to make a form, or like 100 lines of django form trite and all kinds of super().__init__ widget.TextInput workarounds just to change the css on form? After I write Django forms, I look at what I wrote and it's incomprehensible.

4. Unpopular opinion, but Flask documentation is so much better than Django. If you wanna figure something out in Flask, you go to the docs and it's like "okay type this stuff and it will do the thing". If you wanna figure something out in Django, it's like "subclass the user object args to init the method to the routes" when you're just trying to print out some text. It's also badly organized. What is the difference between "try a tutorial", "dive into the documentation?" and "Django overview"? What order does any of this go in?

5. Flask can make pretty decent APIs ootb, and flask-restful just seems to be more documented and popular than drf. And do we need this much bloat to make a basic API that can be spun up in like 5 seconds in vanilla flask? Writing an API in django is like playing pool with a battering ram.

6. Flask generally leads to faster applications because there isn't a million overcomplicated things going on behind the scenes and it is a smaller library.

7. Finally, Flask just gives you a better understanding of how web apps work and knowledge that can transfer into other frameworks. For example, flask uses flask-sqlalchemy. SQLAlchemy is a massively popular ORM that is used in other languages and libraries, so using it in flask gives you a head start when learning other frameworks. You also learn how cookies, sessions, SQL queries, etc work at a fundamental level.

Django all around just reeks rushing out a bloated application to save time for companies. I actually enjoy writing apps in Flask, and interestingly I'm seeing more jobs appear for it nowadays. Django isn't outright bad but I don't see any reason to use it over Flask except for it being more popular.

Finally, a lot of the time saving stuff you can do in Django can be done in Flask. Want a basic app structure ootb? Just make a boilerplate and copy/paste when you want to start a new project. Want an ORM and api stuff out of the box? Just add flask-sqlalchemy and flask-restful to a requirements.txt and write a shell alias to install it all at once when making a new project.

20 thoughts on “I feel like Flask is so much better than Django”

  1. There’s a lot more to learn with Django as it provides a lot more functionality out of the box. You’ll probably come to like it more when you try it with better learning resources and have hit dependency hell with flask or you are writing flask boilerplate code for the millionth time. Neither framework is inherently better, just different.

  2. Gonna be honest, while I appreciate a good rant against Django, it’s pretty trivial to argue against each of these points except number 1 (the least important point you make) and number 7 (which is actually a good point in so far as something like sqlalchemy or marshmallow is concerned).

    Number 2: You’re not actually making cookies, flask and werkzeug is doing 99% of the hard work for you. It’s also pretty easy to code yourself into a plate of spaghetti if you’re not using something like flask-login (which you still gotta build authorization with), in which case it’s fairly indistinguishable from what Django is doing.

    Number 3: wtforms and the flask-wtf extension are pretty similar to how Django handles forms. Additionally, there’s nothing stopping you from just having a form in html and reading the post data in Django yourself.

    Number 4: I won’t comment on the quality of the Django docs as it’s been….6 years since I’ve fussed with Django? Even then, it’s pretty clear to me what “tutorial” va “documentation” vs “overview” are gonna have behind them. Of them, “overview” is the only one I feel needs explanation: it’s probably a marketing page that’s gonna tell me why I should choose Django for my application.

    Number 5: As much as I _loathe_ DRF (as in, I wanna gun duel the guy who made it), layering in a package that adds a ton of features to your framework of choice is gonna come with gotchas and most of the complications and issues I had with DRF were actually Django issues that drf was either embracing or fighting against. That said, there’s enough questionable design decisions that if I had to do Django again, I wouldn’t use it. Flask and Restful have their own gotchas you should be aware of.

    Number 6: I highly doubt that the framework code is the bottleneck in an application, especially a framework as widely used as Django even if it is a large thing with lots of moving parts. More likely is an extension (in house or 3rd party) that has shoddy code, and I’d only go down that path if I’d managed to rule out application code.

    I do find it interesting that every rant and criticism I’ve read never contrast how Django wants to be the foundation for applications whereas flask doesn’t care and is perfectly happy being only the web portion (and I suppose cli portion since click was integrated).

  3. A few weeks ago I set out to play with Heroku. Python is my current preference so I went with their “getting started” page for that. It used Django and was an easy enough setup since all you have to do is clone their sample project and deploy.

    I tried to understand the code behind the sample and found it really hard to pick up on what was happening. I thought maybe researching the Django doc would provide more clarity with an easier example.

    Five pages into their tutorial and I was thinking it would take me months to get something decent off the ground with it. And that’s if I could keep my focus long enough to finish reading the basic docs. I checked out Flask and it made MUCH more sense to me and had a minimalist approach that I could appreciate.

    Django seems like a framework meant for larger teams to manage the Model, Templates, and Views separately. Of course, this can probably apply to Flask apps depending on scale.

  4. Flask is more modular which is great for micro service architectures (k8s). Django is traditionally MVT monolithic and older architecturally.

    Flask takes more work to get to a functioning website (albeit not a ton), and Django you just install it and you have a functioning website.

    Flask is whatever you want it to be and nothing more. Django can be almost whatever you want with a ton more you don’t need.

  5. I like Django’s convention over configuration approach. Having “lots of files” means I know exactly where to debug things every time, even if I haven’t touched that code in months. I did a large project in Flask, and then I learned Rails, then Django, and now I just use Django.

  6. I definitely appreciated using Flask when I kicked off some of my first projects. I had toyed around with Django but it abstracted so much that it was confusing. In general, I’m not a fan of magic. I want to understand why it works. I found that easier to do with Flask.

  7. I too am a lover of flask and believe it is generally better than Django. However, Django and Flask aren’t designed to solve the same problems. If you have 30/40 buisness databases and you want to build quality WebApps quickly to give basic crud access to those databases. Django is going to be almost perfect for you and I’ve seen that work great many times. Flask will require you to get too far in the weeds to spin things up fast, even if ultimately you can build a better, cleaner set of WebApps with Flask.

    In other words, Django is “batteries included”. It’s there to tell you how to solve your problem and if you accept it’s Djangoness you’re going to have a very stable, well supported web app for the next decade or so.

    Flask “gets out of your way”. It lets you make mistakes, it doesn’t give you guidance on how to solve your problem and it relies on plugins to solve common problems.

    You can build “better” WebApps with Flask than Django. But the worst Django apps are almost always better than the worst Flask app.

    TLDR. Flask gives you the flexibility to do things better or worse. Django gives you a supportable problem for a nice large set of common-ish use cases. They solve different problems.

  8. You’re awfully wishy washy. A month ago you were complaining just as much about flask.

    You really can’t compare the two as their use cases vary wildly. It’s like comparing a knife to a blender. They’ll be used for very specific things. Sure there’s some overlap, but neither is meant as a full on replacement for the other.

  9. It just different philosophy. Flask is more my style, keep it as simple as possible, and just add things you need.

    Big everything-included systems like Django, they start to be a problem as soon as you need to do something that the developers didn’t think of.

    I had the same headache with systems like Drupal.

  10. After working with flask for about 4 years i am currently doing a project with Django just to check and see how it works.

    I have to say the documentation is pretty awesome actually and I found it easy to get things up and running in particular because I also know flask. Django has a lot of stuff already in it (batteries included) that i would otherwise have to either write myself or use extensions for. And I have had mixed luck with flask extensions. About half the time I installed something it wouldn’t work and/or the documentation was lacking or wrong. This is quite a contrast with Django where things are all included and can be switched off when you don’t need it.

    All in all i quite enjoy Django for this moment and I am happy i can work with both. I think I’ll keep using flask for small apps that only need a few routes where Django is overkill. But for larger projects will probably use Django.

    Just my 2 cents

  11. i’m sick of people arguing about frameworks. i use both flask and django professionally (plus a bit of fastapi, another framework which seems to bring holy war to reddit) and they each have their place. tools are tools.

  12. Having worked with both frameworks (and had to pickup/maintain existing projects in both frameworks) for a long time now, I almost always use Django for any non-trivial project.

    There’s no doubt that the learning curve is higher — django is a large and opinionated framework, but that pays huge dividends, especially when you don’t develop in a silo. Every Django developer on the planet can walk into someone else’s Django project and pretty much be on the same page, because we all do things “the Django way”. The framework also enables easy distribution of modular apps — something that’s not really practical with Flask.

    Flask, by contrast, is a micro framework that doesn’t do too much out of the box. You get a lot of freedom in how you choose to implement things and there’s not much you need to concern yourself with to bang out solutions, but this is a double-edged sword… I have so many battle scars from picking up random Flask/FastAPI projects across the company and trying to reason about them. Between 20 or so projects, there’s about 15 different ways the same principle tasks are accomplished, which is a pain.

  13. They are simply playing in completely different arenas.

    Flask is a “microframework”: it aims to give you the tools to build web applications, and nothing more, and it tries to be as unopinionated as possible. The main beef is “a web application is an object, where each route is a method”. On top of that, it gives you a small set of helper functionality for doing things like applying jinja templates, or responding with an HTML or JSON body without jumping through a bunch of HTTP hoops, but that’s pretty much all it does. Map requests to method calls, and method return values to responses.

    Django is much more of a heavyweight, comparable to things like, say, Rails – it’s much more opinionated, and it gives you not just HTTP routing and HTML templating, but also a premeditated database access layer with automatic schema construction and migration, a turnkey data administration backend, and all sorts of tools for working with your data, and it’s basically “batteries included”, whether you actually need all those batteries or not.

    If you don’t care much about how it’s done, and your web application is a run-of-the-mill CRUD thing, then Django is going to get you there much faster – but of course you pay the price in reduced flexibility, and when you need things that go against the opinions Django caters for, you will be fighting the framework. Flask gives you more flexibility, but that also means you need to reinvent a couple more wheels yourself. It doesn’t get in your way when you need to do things differently, but it also doesn’t help you as much when you need to do boring standard things.

  14. flask vs django is maybe similar like python vs c++, flask and python are made for humans, not native devs, c++ is made for serious geeks, for core programming everything .


Leave a Comment