TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Django vs. Flask

25 pointsby pygixabout 8 years ago
I am noob to programming, python, and of course web development. Which framework django, or flask to start learning?

10 comments

lastofusabout 8 years ago
Flask for learning from the ground up. Django after coming to the realization that large Flask projects end up cobbling together 80% of what Django offers, usually poorly.
评论 #14026139 未加载
评论 #14029268 未加载
joeclark77about 8 years ago
It depends on the application. Do you care about how things work inside your database? Do you want to understand how the subsystems of your app (like authentication, security, the API, etc) work? Flask allows you (and forces you) to make your choices explicit. Django makes the decisions for you and hides its workings under layers of abstraction.<p>I can see using Django to rapidly prototype some kind of CRUD app, but on the other hand, you could just use Wordpress for that. Flask seems like it would be a superior platform for engineering anything non-trivial, especially if you care about how it works.
评论 #14026231 未加载
jventuraabout 8 years ago
My suggestion for beginners:<p>- If you want to do simple apps that do not touch the DB, or any kind of persistence, you can start with Flask. Much simpler to start.<p>- For a more integrated experience on web development, including DBs, use Django. Their tutorial is very very good: <a href="https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;1.10&#x2F;intro&#x2F;tutorial01&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;1.10&#x2F;intro&#x2F;tutorial01&#x2F;</a><p>I teach these subjects in a local university to BSc and MSc students, and since I want them to learn fast and lots of functionalities regarding web dev, I go directly to Django (after teaching them basic http with python and sockets - like this: <a href="http:&#x2F;&#x2F;joaoventura.net&#x2F;blog&#x2F;2017&#x2F;python-webserver&#x2F;" rel="nofollow">http:&#x2F;&#x2F;joaoventura.net&#x2F;blog&#x2F;2017&#x2F;python-webserver&#x2F;</a>).
tonyabout 8 years ago
You can get pretty far with Flask. You&#x27;ll need an ORM, so you&#x27;ll likely chuck SQLAlchemy in. Then you&#x27;ll want easier access to SQLAlchemy, sorta like, you know, django does it, so you pick up <a href="https:&#x2F;&#x2F;github.com&#x2F;mitsuhiko&#x2F;flask-sqlalchemy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mitsuhiko&#x2F;flask-sqlalchemy</a>.<p>But you can&#x27;t use pure SQLAlchemy models (easily), since this otherwise great extension for flask doesn&#x27;t support it (<a href="https:&#x2F;&#x2F;github.com&#x2F;mitsuhiko&#x2F;flask-sqlalchemy&#x2F;pull&#x2F;250" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mitsuhiko&#x2F;flask-sqlalchemy&#x2F;pull&#x2F;250</a>, yes I&#x27;m in the thread).<p>You&#x27;ll fork it or brew your own code to get declarative models working right. Kinda time consuming, but at least your models can be pulled in by <i>any</i> python code, and aren&#x27;t tied down to a framework (That&#x27;s what you were avoiding from the first place, wasn&#x27;t it?)<p>Then you&#x27;ll pick up WTForms (<a href="https:&#x2F;&#x2F;wtforms.readthedocs.io&#x2F;en&#x2F;latest&#x2F;" rel="nofollow">https:&#x2F;&#x2F;wtforms.readthedocs.io&#x2F;en&#x2F;latest&#x2F;</a>), another excellent library. And you&#x27;ll miss having Django ORM&#x27;s rich form and model-backed validation. So you&#x27;ll try wtforms-alchemy, <a href="https:&#x2F;&#x2F;github.com&#x2F;kvesteri&#x2F;wtforms-alchemy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kvesteri&#x2F;wtforms-alchemy</a>.<p>Then you&#x27;ll begin to see why Django makes sense after using Flask for a while. Django pulls in all the essential stuff and supports it well.<p>And top of that, django&#x27;s addons like django-extensions (<a href="https:&#x2F;&#x2F;django-extensions.readthedocs.io" rel="nofollow">https:&#x2F;&#x2F;django-extensions.readthedocs.io</a>), which gives you Werkzeug&#x27;s debugger if you use .&#x2F;manage.py runserver_plus. And .&#x2F;manage.py shell_plus, which integrates with ptpython&#x2F;ipython&#x2F;bpython (<a href="https:&#x2F;&#x2F;django-extensions.readthedocs.io&#x2F;en&#x2F;latest&#x2F;shell_plus.html" rel="nofollow">https:&#x2F;&#x2F;django-extensions.readthedocs.io&#x2F;en&#x2F;latest&#x2F;shell_plu...</a>).<p>Django rest framework, DRF for short (<a href="http:&#x2F;&#x2F;www.django-rest-framework.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.django-rest-framework.org&#x2F;</a>), which is very mature at this stage, runs circles around Flask API. Flask API is inspired by DRF. You could also try <a href="https:&#x2F;&#x2F;flask-restful.readthedocs.io" rel="nofollow">https:&#x2F;&#x2F;flask-restful.readthedocs.io</a>, but after all that, you&#x27;ll be missing that tight model support.<p>You&#x27;ll <i>love</i> flask. The code is top tier and exemplary. The testsuites are a dream and are very clear. Documentation is awesome. It feels good to code in it. But django feels good to code in as well.<p>Django&#x27;s ORM is very mature. It&#x27;s easier than SQLAlchemy, and despite SQLAlchemy&#x27;s purity, and documentation - even better than flask&#x27;s - Django&#x27;s ORM does the trick for pretty much anything, even foreign databases I&#x27;ve interacted with. Another thing, QuerySet&#x27;s are a charm, a lot of django&#x27;s addons like django-filters, django-rest-framework and django-tables2 are built on top of its versatility.<p>Another thing Flask community ends up having to clone from Django is django-debug-toolbar <a href="https:&#x2F;&#x2F;github.com&#x2F;django-debug-toolbar&#x2F;django-debug-toolbar" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;django-debug-toolbar&#x2F;django-debug-toolbar</a>. See <a href="https:&#x2F;&#x2F;flask-debugtoolbar.readthedocs.io" rel="nofollow">https:&#x2F;&#x2F;flask-debugtoolbar.readthedocs.io</a>.<p>Again, I love flask, but when I realized that I&#x27;m just going to end up reinventing django with my flask app anyway, I started going with django on new projects. I haven&#x27;t turned back, but still check out flask and sqlalchemy to see what&#x27;s happening now and then.
评论 #14026132 未加载
评论 #14026213 未加载
评论 #14031575 未加载
zntabout 8 years ago
You should try both. Choose a project and implement it using the two.<p>Start with a basic todo list. Then add support for permissions. Then add support for versioned entries. Then add a REST layer on top.
tedmistonabout 8 years ago
You&#x27;ll learn more starting with Flask because it provides less layers and components (and a far smaller codebase). Eventually you&#x27;ll build up several of the pieces yourself or combine various libraries and eventually realize it would be much simpler to rewrite in Django. At least that&#x27;s how it&#x27;s worked out over the past few years for me on anything over 100 lines or so.
jeromesalimaoabout 8 years ago
I&#x27;m also a noob. To hack together a quick app to hit a few of the instagram endpoints I went with flask. In my case, it was just a matter of writing a few annotated methods, and plugging in some template files and I was up and running in a few hours!<p>I&#x27;m now looking at SQL alchemy and thinking I might try to taking another look at Django...
fiftyacornabout 8 years ago
Django - but my advice is not to start from two scoops - its a great book but your best bet is to work off the djangoproject, or djangogirls tutorials as thats the common project structure. once you have a handle on this start reading two scoops
yoongkangabout 8 years ago
Django because there are a lot more resources, and the community is pretty welcoming to beginners -- so it&#x27;s very easy to find help.<p>If you are in need of a beginner-friendly tutorial, I would recommend the Djangogirls tutorial.
tixocloudabout 8 years ago
Although we use Django, I think Flask is a great starting point for learning web development.