7
24 Comments

Do you guys recommend Flask or Django for web apps?

I'm working on integrating a software tool (built in python) into a web application. I haven't really messed with either, so I was just wondering if you guys had a preference or suggestion.

  1. 7

    There are several things you have to take into account when choosing one or the other. If it is an internal tool, where you just need people to tweak some parameters and trigger a task, Flask will get you up and running very quickly.

    If you plan to release the app as a website, open to the world, you need user registration, database migrations, etc. Django makes your life super easy. Since you have no experience with either of them, I would suggest you to follow a quick Django tutorial, like Simple is better than Complex. Then, you can quickly check an equivalent tutorial for Flask. That would allow you to understand the differences between one and the other frameworks.

    To keep in mind: Django comes with a lot of things built-in. It is called opinionated, because developers force programmers to do things in a certain way. You have to understand that those developers have plenty of experience, and thus the decisions they made were thoroughly thought. On the other hand, Django takes care of a lot of things that are common to all websites (sign up, login, creating data in a database, altering, deleting, etc.).

    Flask doesn't do anything like that, you will have to take care of tamplates, databases, etc. on your own. This gives a great deal of flexibility. However, if you follow a tutorial blindly, you will end up with an opinionated setup, just like Django, but with many more things to maintain.

    Some personal examples, to have a taste of why one or the other:

    I've used Flask to monitor the temperature and humidity in my lab. I created a very simple web server on a raspberry pi that would accept data from sensors around the room. Then, a mesh of sensors would post the data to the server via the WiFi, and I could monitor the temperature by accessing the IP of my raspberry pi. I was saving the data to data files, so no database, etc. developing was a breeze.

    I also built a website for my wedding, and in that case I chose Django, because I knew I wanted to have a long-in/signup flow. I wanted for our guests to by able to send us messages, update their profiles, see photos, etc. Django made it a breeze. Django also provides an admin interface that allows you to add/edit/delete information from databases.

    I've also created a Flask app to be able to trigger measurements of devices through a network. I didn't need any database, wanted to be asynchronous, and keep track of progress, etc. Therefore, I've extended a Flask app to do exactly what I wanted.

    I am now building a new website for Python for the lab, in which I want users to be able to sign-up to access private content, organize tutorials both in video and writing, etc. I chose Django again for this, because it has some very powerful content management systems, such as Wagtail.

    Hope this points you in the right direction! I think the best is to understand what is the proper tool for the job at hand.

    1. 1

      This is incredibly helpful! Thank you so much for taking the time to respond with all the detail. I think Django will probably be the way i go, as it is for a SaaS startup. It'll be super nice to have a shell for database handling. thank you again!! super helpful!

  2. 4

    Just gonna drop by and say, Ruby on Rails! 😎

    1. 2

      HAHA! Yeah I would, but the backend of the app is already built in python :/

      1. 2

        Haha, go for anything as long as it works! All the best, @LandonR!

  3. 3

    Flask is awesome. Love it!

    1. 1

      Did you have any trouble with database handling?

      1. 2

        Nope. Kept everything in a Postgres dB on Heroku

        1. 1

          Nice, then I’ll definitely look into that 👌

  4. 2

    Django is wonderful!

    Flask is pretty good too.

    Play with them both for an afternoon each & see which you prefer.

    1. 1

      Will do, good point!

  5. 2

    I used both in the past. I recommend to use Django if you'll benefit from the features that it offers by default. It has a steep learning curve compared to Flask though.

    1. 1

      I'm starting to hear that from a lot of people! Thank you for the help.

  6. 2

    Go with Django..

    It has everything you need to develop a soild professional web app.

    1. 2

      I think that gonna be the winner. I appreciate the help!

  7. 2

    Either could fit the bill. I'd suggest whichever you know better (even if marginally), or whichever feels better to you (for example, after going through tutorials for each).

    Django has ORM built in so it's pretty "batteries included" and all nicely integrated. With Flask you usually go with SQLAlchemy, which is more powerful, but also slightly more complex, and the fact that the various tools are standalone means slightly more integration needed.

    But those differences mainly boil down to your preferred style of developing web apps with Python, so if I'd be choosing for myself, the main factor would be familiarity with either, or how comfortable either looks after I have a quick look.

    1. 1

      Thank you for the insights. I really appreciate that! I'll dive into django then, i don't really care to deal with other extra integration if i don't have to.

  8. 1

    I don't really recommend either. Keep in mind that the vast majority of web servers connected to Python services aren't written in Python.

    The only way I'd recommend writing the web server in Python is if that's all you know, you're not interested in learning anything else and you don't care about performance. If all three of those conditions are true, I'd pick Django over flask for anything large. For a pure API, then maybe Flask.

  9. 1

    Caveat: I am not a professional developer, so my opinion comes mostly from a perspective of "what is easier to figure out for the newbie".

    When trying to learn web development I started out with Django and found it hard to figure out because there was a lot of abstraction. The batteries included approach seemed to have the side effect of obscuring a lot of what was going on under the hood. This made it hard for me to get momentum.

    I came back to learn development again and tried Flask this time and found it a lot easier to figure out. You don't get as much functionality, but it is easier to figure out (IMO) because everything is much more explicit because you're doing a lot more yourself. I've also noticed something of an uptick in creation of tutorials for Flask over the last little while, but perhaps that's frequency bias on my part simply because I'm using it now.

    With regards to the "batteries included", most of the stuff that Django does include are somewhat trivial to build into Flask. You can get auth set up pretty quickly, and SQL Alchemy is also easy to set up as well. I also found with Django that if/when you come across things where you want to deviate from their opinionated way of doing things it can be a bit cumbersome to change.

    1. 1

      That’s a really good point actually... as I’m not a professional developer either. Maybe I’ll take that approach and then give django a try. I’ve heard several people say that it wasn’t too hard to combine the database handling to the platform, so that sounds good 👍

      1. 2

        If you need any help getting a starter project set up give me a shout. My gmail is "epgibney".

        1. 1

          Awesome, thank you very much! I’ll be sure to reach out if I run into a wall 🤙

  10. 2

    This comment was deleted 4 years ago.

    1. 1

      I appreciate it. I think django is gonna be the it then!

      1. 1

        This comment was deleted 4 years ago.

        1. 1

          I’ll do that! Thank you 🙏

Trending on Indie Hackers
How I grew a side project to 100k Unique Visitors in 7 days with 0 audience 49 comments Competing with Product Hunt: a month later 33 comments Why do you hate marketing? 29 comments My Top 20 Free Tools That I Use Everyday as an Indie Hacker 16 comments $15k revenues in <4 months as a solopreneur 14 comments Use Your Product 13 comments