One of my more favorite reasons to use Django would be - http://www.django-rest-framework.org/ - whose discoverable API browser is awesome and saves so much time in building out a great REST API with pagination, related resources, and so many other things (plus you can post from the API browser). A bit less so the built-in admin features, which are also nice at times. Possibly also the migrations system. I don't use Django templates, but the rest of it are pretty much great.
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 [*]."
I'll admit I have no idea about Eve, but having used Tastypie, the beauty of Django Rest Framework is its consistency with Django. The Serializers are very similar to forms, and the API views are very like Djangos generic class based views.
Interesting, I take the opposite approach: As your project starts to grow, you end up ripping out the "batteries" of django and implementing other modules. The most notable one would be SQLAlchemy.
Just an FYI, the newest version of Django (1.8) now supports Jinja or Django templates by default and you can plugin other templating engines if you want.
Did you try to use Jinja2 templates in 1.8? There is hell of a bootstrapping to do until you can actually start working with these. Don't even try to use both at the same time within the same project. You'll end up crazy before you can make Django load the right template.
No I haven't, still on Django 1.6 at work but I keep up with the newest developments. That's a shame, from what I read it sounded like it was just a simple config setting that would allow you to use Jinja over Django templates.
I am curious about this. I like Djangos ORM for the basic stuff, but it doesn't work on even moderately complex queries (conditional aggregates are a serious loss). Would I gain much by going to SQL Alchewy over just using raw SQL, which is what I do at the moment? (bearing in mind replacing the Python ORM completely, and you will loose the admin, which I use heavily).
In one project I worked on, I found this to be very true.
We created an enterprise level application, with some constantly shifting specifications.
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.
When I started doing Django projects back in 2007 I certainly found Django very cumbersome - the lack of features in the ORM, the clumsy template language, the terrible authentication system (User.get_profile and so on). I preferred Pylons by a mile (the Flask/Pyramid of its day).
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.
Django/Rails/etc are kitchen sinks. they are not optimized for "building an API", or speed for that matter. it's kind of silly to expect them to perform as well.
you're right, i hope i didn't sound argumentative. i should clarify my own point too, and add that just because they are not "built for it", or are slower, doesn't mean they are inherently a bad choice either. it's really just what you need to optimize for.
A 5x increase is slightly? Yes there is another slide zoomed out showing other frameworks much faster, but still, I'd take 5x over a poke-in-the-eye with a sharp stick if I cared at all about performance.
> Complicated SQL queries are a piece of cake with Django's built-in ORM.
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.
> 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.
You can then access user_id via self.kwargs['user_id'] from within the viewset. And the team ID is implicitly added by the router to support list (and update), and retrieve (delete, put, patch) methods. user_id is also passed as a kwarg to the dispatched method (create, retrieve, etc...)
> Pirates use Flask, the Navy uses Django. WakaTime is a pirate
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?
Ahh! Yes, that's a perfect match for the given context. Thanks!
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 question really is, what's a useful way to determine which of two projects has a "more active community according to GitHub"? Is the number of stars/watchers a good enough proxy to use for decision making?
The projects I use are typically quite small, and my code is on Bitbucket, so I have effectively no experience in this.
I don't think the title refers to the actual US Navy, but rather a "navy" vs "pirates" (as in people who use boats and occupy the open waters). The idea being that Django is more structured and much larger (as a navy usually is), where as Flask is smaller, etc...
Author here. The Pirate/Navy title is a metaphor to say Django is rigid and Flask is flexible. You have to do things the Django way. With Flask, you can customize it easily.
P.S. My cofounder Priyanka said the Pirate Navy line thing when reading the post, and I thought it was an awesome title :)
While I agree with this to an extent (I use Django on a daily basis) Django is pretty flexible.
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.
It's the sort of thing someone says when they think they're an uber-l33t lean agile stealthy ninja rockstar webdevops disruptive buzzword buzzword, in my experience.
I've been using django pretty much since 1.0 came out. Every project I start these days thats a web project, I use django.
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'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).
Personally, I like pyramid as a middle-ground between the two. More to get you started quickly a la Django; less to get in your way as you grow like flask. It tends to hit my needs right on the spot.
I almost started a very major project with Flask, but am glad I did not for how much work DJRF and South had saved.