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.
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.
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!
Just gonna drop by and say, Ruby on Rails! 😎
HAHA! Yeah I would, but the backend of the app is already built in python :/
Haha, go for anything as long as it works! All the best, @LandonR!
Depends what kind of web application you're building. If it's more of a single page app or just a wrapper around some back-end python code then go with Flask, if you need user sign-in and more CRUD features, go with Django. Either can be made to work for any situation but Django is a lot heavier and more "batteries included".
I appreciate it. I think django is gonna be the it then!
Pleasure and good luck!
BTW check out https://www.indiehackers.com/product/justdjango by @mattfreire - he's got some great YouTube tutorials for Django beginners :)
I’ll do that! Thank you 🙏
Flask is awesome. Love it!
Did you have any trouble with database handling?
Nope. Kept everything in a Postgres dB on Heroku
Nice, then I’ll definitely look into that 👌
Django is wonderful!
Flask is pretty good too.
Play with them both for an afternoon each & see which you prefer.
Will do, good point!
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.
I'm starting to hear that from a lot of people! Thank you for the help.
Go with Django..
It has everything you need to develop a soild professional web app.
I think that gonna be the winner. I appreciate the help!
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.
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.
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.
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 👍
If you need any help getting a starter project set up give me a shout. My gmail is "epgibney".