loading...
Cover image for Flask or Django ? Here's what I learned from using both.

Flask or Django ? Here's what I learned from using both.

mr_kryp70n1c profile image Ankit Sridhar ・2 min read

Hello everyone at DEV, I am a self-taught web developer and a learner. Recently I switched to developing web apps in Python and using Python as my server side programming language the two most popular and pretty obvious web frameworks are: Flask and Django. So, I gave both of them a try and made a similar project on both these frameworks using a relatively easy to configure database(i.e SQLite) which won't require a dedicated server to run and work in development.

Here's my view and tell me your opinions:

  1. Both come with the support for Jinja2 template engine and it was the same HTML markup on both. No difference here, even though Django has its own template language it isn't much different from Jinja2.

  2. While Flask is lightweight but it misses on preloaded tools. Unlike Flask, Django comes with numerous ready to use tools out-of-the-box which makes development quicker than Flask.

  3. In terms of project layout and structure Django focuses on building projects which hosts multiple applications whereas Flask focuses on building a single application and add required views and models to the single app.

  4. Flask was easy to learn as compared to Django, it is described as a micro-web framework and referred to as more "PYTHONIC" in nature. Django comes with preloaded tools which is great and doesn't require use of third party libraries but this doesn't enable the flexibility which flask achieves by offering extensibility.

  5. Both have the support for a great and robust ORM system which supports popular databases like MySQL, PostgreSQL etc , Django has a built in ORM which Flask doesn't. If you were to perform these operations you would install another popular python package called "SQLAlchemy".

  6. The biggest advantage that I felt Django had over Flask was the included Admin interface which makes creating a superuser super easy. It also allows customizing the interface and user management from the panel .

  7. In terms of support for security and authentication Django again has builtin modules , you will have to use extensions like Flask-Login, Flask-Security for account management and authorization in Flask.

In term's of performance I didn't really see much of a difference and honestly can't say much.

Posted on by:

mr_kryp70n1c profile

Ankit Sridhar

@mr_kryp70n1c

Hi , I am full stack (MERN) web developer . A CS undergraduate with a passion for technology ✌

Discussion

markdown guide
 

As you describe Django has a lot of precharged tools, but Flask is easier than Django and gives you all the controll off the app.

I think that you have to use either according to the size of the project.
In my oppinion I prefer Flask when I build API's and Django to build bigger projects.