V
V
veitmen2014-04-18 17:18:26
Django
veitmen, 2014-04-18 17:18:26

Django vs Flask?

Hi everybody.
Write or give where to read about a good comparison of these two frameworks. I am familiar with Flask. Like already ears squeak. Should I look into Django? What are the benefits? What are the downsides?
As far as I understand, Django is easier with localization. Or am I wrong? What else?
Of course only versions for Python 3.*
Thanks!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Michael, 2014-05-19
@nextel

Well, 1000 times:
dzhanga - a cloud of batteries, a rigid structure of the application, you don’t really need to think about
problems - everything that dzhanga doesn’t mean, like a template engine is faster, orm another and blah blah blah, you’re tormented, plus deploying it on combat servers is also a task not difficult but hemorrhoids.
flask - I love flask))))) I screwed whatever I wanted, plugins are easier to write, so you can make your crutches as much as you like, quickly deploy on the server? it’s not a problem, it’s easier to land on a Tornado , well, in fact, all this is also its disadvantage. Well, actually advice for comparison here)

K
Kirill Ermolov, 2016-03-14
@erm0l0v

It's actually less difficult to understand the advantages of Flask over Django for a large application. But for some reason, many articles and reports pour a lot of negativity towards django. Here is one of the few reports where flask is not praised to the skies: https://www.youtube.com/watch?v=7SmWn05m1Tk
My opinion listing the advantages of Django. Most likely, these disadvantages are connected with the fact that I didn’t fully smoke Flask or I’m trying to make Django out of it.
1) Django doesn't have the love for global variables that Flask does.

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        do_the_login()
    else:
        show_the_login_form()

Here is an example from the documentation. As for me, the appeal to requestlooks creepy. And accordingly, the question is born what to do if I need to use requestoutside , loginsay, in the method do_the_login.
Should I pass requestin the method parameter or should I still use the global variable request. The first option seems correct to me, since otherwise the dependencies of the method are implicit. But if you stick to the first option, then it is not clear why the global variables were added initially.
There is no such thing in django and all parameters are passed explicitly.
2) Project structure.
It seems that the number of different ways to organize Flask code is equal to the number of applications written in Flask.
This is very annoying because:
In Django, the project structure is identical in most cases, and you shouldn't have any problems moving from one project to another.
3) Good modular system.
In Django, modules can carry a lot of goodies with them, say static files, admin console commands, and all these modules do not interfere with each other. Django modules are self-contained and generally independent of each other, which is a big plus.
Flask modules include a lot less features and are often tied to each other. This can cause version conflicts and lead to a lot of refactoring when you want to add a new module.
4) Admin
Together with django, you will get an excellent admin panel that you are not ashamed to show to the client. Flask Admin Doesn't have as many features as Django's admin + The django admin can be very coolly extended with a huge number of plugins. For example, you can add a plugin that will track all changes in the admin panel with a convenient display of these changes and the ability to roll back to an earlier version if something went wrong.
5) Great Documentation
This is not only about the Django documentation, but also about most of the popular modules. While Flask itself can claim to have good documentation, the modules you're likely to use don't. Thus, very often you have to find out some aspects of the work of the module in the source code, issue, Stack Overflow
I often scold Django for its tight binding to an ORM or a template engine. This is partly true:
you can choose not to use the standard ORM, but you must understand that this decision will deprive you of a huge number of goodies. My personal opinion: Flask is exactly the same if you don't want/can't use SQL Alchemy.
As for the Django template engine, you can use whatever you like, here is an example of a real project using Mako - https://github.com/edx/edx-platform
Django is often criticized for not having to think about it. I think this is more of a plus than a minus. I don't see anything wrong with not wasting time on implementation details, but doing business logic (which is already complicated). Yes, sometimes it can play a trick on you when you want to do something non-standard.
I apologize for the fact that a lot of things may be out of place in this answer, it's just that articles and reports on the topic of Flask vs Django give the impression that Flask is the very silver bullet that we have all been waiting for.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question