4 ms·
The advantage of Django is it comes bundled with everything you could need. Flask is simple, but then you need user authentication. Which library do you use? Is
by orf 9y ago
The advantage of Django is it comes bundled with everything you could need. Flask is simple, but then you need user authentication. Which library do you use? Is it updated and maintained? What about an ORM, forms, templating, localzation. Do they all work together?
Suddenly it's not so simple.
That being said, if your app really is simple (single file, under 100 lines) flask is excellent.
- int_19h 9y agoIf your app is that simple, Bottle is probably a better fit than Flask (even more minimalist and non-opinionated).
- jrs95 9y agoFlask is a great fit with smaller APIs but not tiny like this in my experience. Great support for SQLAlchemy and database migrations. Better than Django ORM in my opinion.
- dizzystar 9y agoOh, come on. There are plenty of large websites written in flask. It's not that hard to use at all, and all those things you list are definitely a part of it. Hell, I have a 20 KLOC website written in bottle, and no one ever said it was poorly done, insecure, and so on. The problem is that a lot of people writing Python web stacks don't know how to write Python at all, and no framework will save that shortcoming.
- orf 9y agoPart of my point was that if your site is going to be 20 KLOC then why not use a framework that is aimed at building 20 KLOC large sites rather than one that is aimed at writing 200 line sites. Flask is advertised as a micro framework. if you want to rebuild Django with it then sure you can, but I personally can't see why you'd want to.
- dizzystar 9y agoFlask is used by Pinterest and LinkedIn, which I'm guessing are a touch more than 100 lines of code. Flask is, of course, more powerful than bottle, and has less batteries included than Django. Saying Flask is good for 100 LOC sites is terrible advice, no matter which way you try to slice it. It isn't. It's widely-used and well-maintained. Don't get me wrong, I like Django as well.
- orf 9y agoI've used Flask for single file sites with 10-250 lines. It's great (ish). What's bad about it? Your saying it's only good for writing large applications? How so?
- dizzystar 9y agoYour contention is that it's only good for small sites. I'm saying it's good for any sized site as long as you actually know how to RTFD and program in Python. Django is no different. Django falls apart spectacularly in the hands of people who can't program.
- thijsvandien 9y agoDoes eventually needing a truck justify driving one when for now everything fits in a van? The structure Django imposes on you may get in the way while you're still experimenting.
- hakanderyal 9y agoWhat I like most about Flask is, it provides the barebones for request/response handling, and gets out of your way. Add SqlAlchemy to the mix, and python handles the rest. I'm using Flask, but building my apps with Python. This simple/complex equation should be reversed IMHO. Want to throw together something quick? Go with Django, where everything you need is built-in. Want to build a big app? Go with Flask, and build your stack specific to your needs. As a bonus, once you have built a complex app with your own abstractions/magic succesfully, it becomes faster for you to build new projects with your own framework than any other alternative.
- simonw 9y agoI've ever understood this argument. Any library you can pick and mix into your Flask app you could just as easily pick and mix into your Django app. It's all just Python.
- Walkman 9y agonot really. Did you ever tried to use SQLAlchemy with Django? Good luck with that.
- ubernostrum 9y agoEver tried using SQLAlchemy with Flask? It's exactly the same situation: either you luck out, and someone already wrote all the conveniences and utilities and integrations with components for you exactly the way you want them with exactly the set of other components you wanted, or you do it yourself. Also, you could make a similar argument about swapping major components into, say, Pyramid. Most of the alternatives people promote to Django are not really some paradise of trivially-swapped-but-tightly-integrated components. They just do exactly what Django does, with a different set of "use these or lose the integration" components chosen up-front for you.
- hakanderyal 9y agoI've used SqlAlchemy with Flask. You only need a few lines of code to integrate them. But yes, with Flask (or similar frameworks/libraries), you need to do the integrations yourself with the components you want to use. Advantage of Flask in this regard is, you don't need to fight with Flask to make it happen. That's why I'm saying it's better suited for complex apps that you want to build with your own abstractions. The real problem is the cargo cult thinking when it comes to frameworks, instead of doing a cost/benefit analysis and thinking about trade-offs. Following statements like "Django for complex apps, Flask for 100 lines of apps" without researching the reasons behind probably will result in more problems in the future.