I almost started a very major project with Flask, but am glad I did not for how much work DJRF and South had saved.
"Eve is an open source Python REST API framework designed for human beings. It allows to effortlessly build and deploy highly customizable, fully featured RESTful Web Services.
Eve is powered by Flask, Redis, Cerberus, Events and offers support for both MongoDB and SQL backends [*]."
 - https://django-tastypie.readthedocs.org/en/latest/validation...
In most real-world projects started using Flask - you end up reimplementing half of Django badly by the time you're finished.
- Jinja instead of Django templates.
- Custom (and sane) class-based views instead of Django's disgusting defaults.
- Custom class-based settings.
- There's no way to define app-only middleware in Django. Flask blueprints make it trivial.
However, 10 years later and no framework has come close to Django's true strength: built-in admin.
Flask vs Django was a huge point of contention between the two lead developers. One even quit over Django being chosen.
By the end of the project, we ended up using a ton of django's features. The business functional specifications changed, we did some research, and found out it would be easy to handle via slight extension of some already built-ins to django ex. template loaders,middleware,sites,and signals.
It saved us a ton of time.
I feel pretty safe saying I would use Flask for small very clearly specified projects, but otherwise I would probably choose Django.
Django in 2015 though pretty much does everything I need. I still have gripes but when you factor in extras like the Django Rest Framework it's still my go-to for new projects unless it's something completely unusual.
It's built by the folks at Rackspace and it's super fast because you can build it using Cython and because it's just a very thin layer over wsgi. We switched over to it from Django and saw a 10x improvement in response time.
so many ways to skin a cat...
Flask serves JSON responses slightly faster than Django.
1. Have you been coding for more than 5 years? (yes:'Flask', no:'Django')
2. Have you coded in Python for more than 3 years?(yes:'Django', no:'Flask')
3. Do you like reading Python code? (vs reading docs)(yes:'Flask', no:'Django')
4. Will you have an API? (yes:'Flask', no:'Django')
5. Will your site primarily have dynamic HTML pages? (yes:'Django', no:'Flask')
6. Will you use Service Oriented Architecture (SOA)? (yes:'Flask', no:'Django')
7. Using an SQL database? (yes:'Django', no:'Flask')
8. Want new devs to already know your conventions? (yes:'Django', no:'Flask')
I disagree here or maybe "complicated SQL query" means something entirely different to me. I've found the ORM to be great for straightforward to reasonably involved queries. However the moment you start trying to improve the database performance, you need to drop to SQL. It's another story that SQL is a lot more difficult to maintain and not very DRY across modules.
> Flask > Django for APIs. For example, a nested api resource in Flask is
> @app.route('/users/<string:user_id>/teams/<string:team_id>', methods=['GET', 'POST'])
> while with Django REST framework this is impossible.
> (drf-nested-routers helps but breaks unless you use only the most basic Django REST framework features.
Is this really true? For a start I've managed to build a complex app without needing nested routers (although they are cool). Second - I've used DRF extensions nested routers without finding any problems.
For me needing an API is a point in favour of using Django for a lot of use cases - you get an elegant declarative syntax and lots of batteries included.
router = DefaultRouter()
It's fine to be able to add a user to a team by posting to a subcollection though, but there should only be one URL for the resource (IMHO).
Right now it's a hack that limits your api features, but might change in the future.
I don't understand this. According to Netcraft, the US Navy uses Active Server Pages and the UK Navy uses ASP.NET. While there could be Django somewhere in there, there's likely also someone in the US Navy using Flask. I wasn't able to find a source which says that US Navy has decided to use Django for most of its web development - I think it would be pretty surprising for the US Navy to switch to Python over a more traditional enterprise solution!
More likely this is some pop culture culture reference I don't get. Anyone care to explain?
I question the assertion "Django is older and larger, but Flask has a more active community according to GitHub." Surely the number of stars and watchers don't mean that those people are active in the project. According to the github pulse reports for the last month:
> Flask (March 23, 2015 – April 23, 2015): Excluding merges, 19 authors have pushed 23 commits to master and 69 commits to all branches. On master, 16 files have changed and there have been 340 additions and 43 deletions.
> Django (March 23, 2015 – April 23, 2015): Excluding merges, 124 authors have pushed 189 commits to master and 608 commits to all branches. On master, 2,395 files have changed and there have been 25,689 additions and 84,146 deletions.
By those numbers it seems that Django has a much more active community, in the sense of making code changes. There are other types of activity than code commits, like support, conferences, etc. I don't get the sense that Flask is more active there either.
Edit: If it is meant as an allusion to the Mac/Apple][ era at Apple then activity is a poor measure - there was much more activity and general interest in the Apple ][ during the Mac development.
The projects I use are typically quite small, and my code is on Bitbucket, so I have effectively no experience in this.
P.S. My cofounder Priyanka said the Pirate Navy line thing when reading the post, and I thought it was an awesome title :)
If your app falls outside of a certain set of assumptions I would go for Flask (which I considered for a project we are working with). I would say that Flask apps need to be doing something special before Django is not considered.
The main reason why I use django is because o the ORM and the admin. If I were to do a project in Flask, I'd have to build mt own admin, and i'd have to use SQLAlchemy. I had to use SQLAlchemy once for a project and I hated it.The django ORM is much more straigh forward an easier to use, in my opinion. In my 10 years of using django ORM, I have had to "break out of the ORM" maybe once.
I have a hunch that uuid's or other non-semantic primary keys are a good example of of 'practicality beats purity'.
I'm a huge fan of bottle.py, it's simpler/cleaner, but does lack of fucntionalities and plugin. And you'll notice that it is much higher on the the JSON serialization chart at 13% (flask and django are at 5.7% and 1.1% respectively).
Thanks, this really helps a lot! LOL
Anyone have a mirror?
The page loads for me just fine.