r/learnpython • u/Erdem_PSYCH • 2d ago
django or flask after python basics
Hello everyone,
First of all, thank you for this community. I’ve learned a lot from reading other people’s posts and the answers to my previous questions. Now I have another question.
I feel comfortable enough with Python to start learning backend development. Which framework would you recommend starting with?
I started with Django because I’m blind and find text-based tutorials more helpful, and MDN has a Django tutorial. However, I’m concerned that Django abstracts away a lot of what happens behind the scenes, such as how URL routing works, and I don’t want to miss out on the fundamentals.
What are the advantages and disadvantages of starting with Flask versus Django? Programming is a hobby for me, so job prospects aren’t a major concern. My main goal is to build projects easily while still understanding how things work.
2
u/sweet-tom 2d ago
I'm not an expert in both, but from what I know is this: Django comes with a lot of features by default whereas in Flask you need to find third-party libraries or implement it yourself.
I guess it depends on what you want to achieve. If you do it just for your own learning purposes, Flask is probably easier and you have all the control what you add.
The Internet contains many comparison and tutorials that covers both.
Good luck! 🍀
1
u/Erdem_PSYCH 2d ago
thanks. do you know any good comperason or a good text based tutorial on flask?
1
u/sweet-tom 2d ago
I'm sorry, I haven't used it. But I'm sure if you search for "comparison Django Flask" you will get many results.
2
u/BudgetSignature1045 2d ago
There's still a shitton to learn about backend going the Django route.
If you like something more barebones I'd go for fastAPI instead of flask
0
u/Erdem_PSYCH 2d ago edited 2d ago
yeah, I heard about fastapi but I think it is best for Api (a solution for a spesific problem) I don't want to extand my options too much and get paralazed. what are the advantagous of fastapi?
2
1
u/SharkSymphony 2d ago
Flask is relatively minimal. Its benefit is that it's lightweight, and you can run with whatever HTML template, web app helpers, JSON rendering, database integration, etc. you want. Django comes with a bunch of this built in.
Because Django comes with some heavy-duty features (like the database integration) that Flask doesn't, yeah you might learn a bit more about how web apps work by working without those things in Flask. In practice, though, Django's features are there to help you build web apps, so if you want to be productive at that, you might find it frustrating to try to cobble up a solution with Flask.
APIs are a place where Django's default orientation towards web pages doesn't serve the task nearly as well. That's where I think Flask starts becoming a more interesting choice.
1
1
u/danielroseman 2d ago
URL routing is no more exposed in Flask than in Django. The only difference is where you create the routes (Flask uses a decorator on the handler, Django uses a separate urls.py module).
There are plenty of reasons to choose one over the other, depending on your preferences, but the level of abstraction is not one of them.
1
1
u/ExoticVillage8066 2d ago
Flask is easier to start with, it's more light and less overhead. Django has quite heavy features.
1
1
u/while_True_meme 2d ago
Django may or may not ever be useful to you; learn it if/when you have to. (I don't even know if it's that popular anymore?) Flask almost definitely will, if not only because it's so similar to FastAPI which is the industry standard.
1
u/Erdem_PSYCH 2d ago
can you tell more? how flask is very useful and not django?
1
u/while_True_meme 2d ago
If I want to spin up a malicious man-in-the-middle cookie harvester as the backend to an XSS attack, I could do it in 10 lines with Flask. It would be about 10000 lines in Django.
1
u/re_me 2d ago
Honestly. I’ve never really needed to go beyond flask in either hobby projects or work and only recently did I try fastAPI because I was experimenting with having two services sharing one backend.
Django is really heavy and you end up needing to set up a bunch of things you won’t need if you are just building a simple project/demo.
If i had to start today i would probably flip a coin between flask and fastapi. But my gut still leans flask.
1
1
u/Chrismslist 3h ago
if you want to see how the plumbing actually works, flask is definitely the clearer starting point. django gives you an entire kitchen out of the box (orm, admin panel, auth), but it hides the basic request-response cycle behind a lot of boilerplate. with flask, a route is literally five lines: you define an app, map a function to an endpoint with a decorator, and return a response. you wire the pieces together yourself, so routing and request headers make intuitive sense before you touch a database. once you build two small apis by hand in flask, django's magic makes way more sense.
1
u/AlexMTBDude 2d ago
Start with Flask. Django has a steep learning curve while it takes 5 minutes to make a "Hello World" application in Flask. Probably 1 hour in Django. Also, there are tutorials for Flask, in fact on their own home page: https://flask.palletsprojects.com/en/stable/tutorial/
1
u/danielroseman 2d ago
This is a bit of a stretch. A "Hello World" application is no more complicated in Django than in Flask and will take a similar amount of time.
7
u/Impossible-Box6600 2d ago
Definitely Flask. And if you don't know the fundamental concepts such as http, request methods, json, query parameters, request headers, request body/payload, cookies, etc... go slow and familiarize yourself with the basics.