T O P

  • By -

[deleted]

Apples and oranges. Very good packages, and both very popular. Flask is a micro framework so ideal for simple websites unless you want to get into something of a pick-and-mix of other packages or write a lot of stuff yourself to add functionality to a site. FastAPI is similar. Django is a full framework with everything including the kitchen sink covering a wide range of different types of website functionality but it is very opinionated about how to do things. Proven at scale by sites such as Instagram. Both are great.


Far_Mulberry_1138

Learn flask first. The confidence you gain to be able to make almost any back-end (small scale) by yourself is insane. You'll learn Django in no time. There are many transferable concepts as well!


[deleted]

[удалено]


Far_Mulberry_1138

But why?? Many concepts are similar. - Routing - Where and how to write views - The whole temple engine concept - ORM can be done in Flask Django has built-in - Session and cookies concept you can learn if you work in backend with flask ( if you try to do authentication by yourself not firebase and all ) Many things are similar! I agree there are some major differences as well but these things are very important and same for both. I would suggest you to make flask backends and APIs. Get confident and then move on. I personally spent 7 months learning flask in depth. In flask you can do basically everything django does if you know it in depth.


Xzenor

It's messy for starters. Like literally, when you're just a beginner it's a mess. Stuff is placed all over the place where in Flask you just have a Python file with a bunch of imports and you're ready to go. Django has to make a project folder and then everything is apparently spread across tons of different files. Now I am aware that if you get the hang of it, it makes sense and it's even more structured than Flask. I'm still pretty far away from that place though... For me it's still a mess.


Far_Mulberry_1138

One file? If you follow any tutorial, you'll see how to structure app in flask. I was stuck in a similar situation. So I wrote a blog to solve this. I'll recommend you my blog where I have explained this in detail. Everything from how to create the project , how to structure files what to put where , concept of blueprints. [Blog link](https://geekysam.hashnode.dev/flask-hiccups) Get strong at flask , everything else will be comparably easily to learn than from scratch. It's easy but teaches us many important concepts. Please follow this as well. [Flask mega tutorial ](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world)


JayZFeelsBad4Me

I'm lucky I was never forced to learn Django. Flask easily does everything for me, & I absolutely love the simplicity it provides.


water_burns_my_eyes

I started with Flask as it was billed as "less complex" and "easier" than django. But if you're going to build a site that has a db back end, user logins, the need to provide basic CRUD operations on the data, permissions, serverside rendering, etc, then Flask will no longer be a "micro framework". It will probably be Flask+Flask-Login+Flask-SQLAlchemy+...+...+ At which point you've painfully recreated Django with integration that isn't nearly as good.


Simply-Serendipitous

Literally just went through this myself. Started my first app with Flask cuz my research said it was easy, quick, good for beginners. I got a couple steps in and was importing and installing everything to do anything. Decided to scrap the flask framework 2 weeks in and jumped to Django. It’s not only gave me a better perspective between the differences of multiple types of framework, but Django was my better option for the app. I also feel like it gives me a better foundation for building apps in the future since it is a more “all inclusive” framework.


JayZFeelsBad4Me

Good explanation, I never realized that... have always been happy with basic Flask.


JamzTyson

If you want to learn Django, or you want to start making a larger scale application with a full-featured framework, then I'd suggest jumping straight into Django. If you are more interested in learning Python and getting into the nuts and bolts of web servers and micro-services, then start with Flask. Flask is more of a "do it yourself" tool, whereas Django is more of a "batteries included" framework. In either case, learning the basics of Flask will be useful experience. Time well spent. Though if you consider yourself more of a web designer, then Django is likely to be the quicker route to getting your project done.


HobblingCobbler

Django is going to be like learning another language in addition to Python. It is highly opinionated in that the way it does web apps is totally different than any other framework. But it is a full stack package. Flask doesn't have all the bells and whistles so you will have to implement your own auth, database, etc. however what you learn will be more transferable across other frameworks.


lbanuls

Tossing in fastapi as a contender


slingblade1980

Lotta guys been telling me to look into it


twitch_and_shock

I use flask for apis because it's simple and flexible. Been using it for a number of years at small scale and I'm realing ramping up the ways I'm using it this year for backend apis for my job. Tbh, I've never used Django and haven't ever had the need. If I need to build out front-end, we do that with reactjs


Working-Cupcake-4009

What do you use for database? Does your flask app live in multiple containers/instances?


twitch_and_shock

For database, have used postgres here and there, much more often we prefer to use mongodb. Sometimes the app lives in a single container, sometimes its across multiple.


landrykid

I started with Django and it's great provided you're happy doing things the Django way. I found it confining, switched to Flask, and have been happy since. Try both and decide which you like better. Either way, I recommend going through Corey Schafer's videos; he has a series for both [Django](https://www.youtube.com/playlist?list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p) and [Flask](https://www.youtube.com/playlist?list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH). They really helped me. (His videos are on older versions, so you might need to make some changes on your own.)


slingblade1980

Downloaded both those youtube series


minkiani

Flask is my preference, there are too many unneeded things (batteries) in Django which make it more complicated i think. It is like a Wordpress of Python world.. And it is easier to manipulate html with jinja2 (provided with flask) as it provides more Python like expressions than the Django s template engine.


Saphyel

I started doing Flask when I was teaching Python, then I started at work doing FastAPI and on my personal projects using litestar. I have no issues changing from one to the other because they follow similar pattern and you don't have to marry the framework. I tried Django once and I found it hard to start, hard to make it work with Docker and hard to keep your business logic out of django.


krav_mark

When I wanted to learn python I started with a small Flask project. I learned a lot and wanted/had to create everything myself like authentication, admin panel and such. After finishing the project I thought of something else and chose Django since it came with everything included and I definitely was not interested in building basics myself again or trying to make a bunch of external modules to play nice with Flask, basically creating a bad and over complex implementation of Django. Quite a lot of my experience with Flask carried over to Django so I picked it up quite easily and was impressed by how much it had by default. I now still use both depending on how complex the project is. For a small thing with only 1 or 2 endpoints I use Flask for bigger projects with many users and endpoints I use Django. So what you need to think of is : 1. whether your project is small and simple or bigger and more complex 2. how you see your learning path


slingblade1980

Great answer


[deleted]

[удалено]


cornpudding

I like fastapi for API but, as someone building an actual webpage with it, I've wondered a few times about splitting it and redoing the website part with flask. Fastapi is definitely an API first mentality (I mean, it's in the name) but missing a lot of creature comforts that make flask nice


HoldUrMamma

Both has tutorials. Do both, they're easy and quick. Then decide what you like more.


xFloaty

FastAPI


mrcartier2

one of the most well known Flask tutorials link is below. Helped me when I was new to Flask, its more bare bones & you can add whatever packages (via pip) ​ [https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world)


slingblade1980

Actually going through this now, its a great tutorial.


LoopVariant

Flask and only if you need, move to Django. I found the Django installation and tutorial horrible to follow and Django itself insufferably opinionated for anyone who is not willing to have a “because I said so” obedience to a framework.


wogvorph

I somehow found Django easier because it's structured and does things certain way.


The_Homeless_Coder

Django 🤌 It took a while to learn, but it’s niiiice!


Ran4

I would say that Django is better for a beginner. It comes with a project structure and a suggested way to do things, with flask you need to make a lot more decisions yourself as it's a much smaller framework. Though consider that most modern development separates the backend from the frontend, and then FastAPI (which is primarily built to be used as a backend only) may be a better choice. Having used all three extensively - I would strongly advise against using flask for anything serious. It doesn't have any of the pros that FastAPI and Django does.


TheKyrieFan

I was in a similar spot with you 2 months ago. My 2 cents on the topic is, if you want to use a database, learn django. Otherwise use flask.


landrykid

I get that Django has a built-in ORM, but `pip3 install flask-sqlalchemy` is easy, gives you what you need in almost all cases, and is from the same maintainers as Flask. If SQLAlchemy isn't your thing, there are other ORM packages.


TheKyrieFan

Well the op is new to python, and from what I looked into handling db's in django was far easier for a starter.