6 ms·
Ask HN: Django or Flask as first web framework?
I am in the process of learning Python for web development and I think I am the stage where I should start learning a web framework(did not use one before in another language). My html and css is ok.
I have picked Python for fast web development and that is why I think I should just dive right into Django. However I have seen plenty of advice that it would be good to start with Flask(or other smaller framework) to learn better the inner workings of the framework.
What would you advise?
As I learn better from videos do you know of any good videos to learn the advised framework? What about books or tutorials?
What do you wish you knew or learn when you were just starting with the framework?
Thanks, Adrian
Update!!!
Thanks everyone for your comments. So I will be starting with Django and so far I have as resources Django docs and the upcoming video series. Is there anything else you would recommend as tutorials?
Asuming I am a fast learner and I learn this full time how long should it take before I can start building my own web apps?
- napoleond 14y agoEither one is great. I started with Django and now prefer Flask; unless you are starting out with an enormous project I agree with the recommendations you have received--you will get a better sense of what's happening under the hood with Flask. I don't like learning from videos so can't help you there, but http://djangobook.com http://djangobook.com is awesome for learning Django, and the Flask documentation is sufficient too.
- adrianmn 14y agoIs the Django book updated? The notice where it asks for help to get it updated it scared me as a newcomer(and probably many others) as I won't know to judge if what I read is updated material or not. I understand this is an open source project but from the business perspective that notice is completely missplaced. The people looking there want to read the book and what they learn is that is outdated. The targeted audience that can actually help update the book most likelly hangs out somewhere else.
- martey 14y agoI can't speak to the status of the Django Book, but Django's official documentation is up to date and just as (if not more) comprehensive. Version 1.4: https://docs.djangoproject.com/en/1.4/ https://docs.djangoproject.com/en/1.4/
- padobson 14y agoI recommend Django because it's much more widely used. You'll find more write-ups, Stack Overflow questions, podcasts and conference videos. Instagram uses it. Disqus uses it. There's just a ton of help out there for a new developer. While I agree that a lot of what Django does seems like "magic", getting to know how that magic works as you get more intimate with the framework will make you a better developer in the long run - so you can start writing your own magic.
- adrianmn 14y agoThis is what puts Django on top of my list so far. It would be more fun and productive if I can just start doing web apps and I can always jump in and learn some of the magic behind it in the future.
- Rev55 14y agoHi Adrian, I would recommendation is django, but there currently are no good tutorials for it. Kenneth Love (https://twitter.com/kennethlove https://twitter.com/kennethlove) is creating django video series that should be available in December. In the meantime my recommendation is as follows: 1. Make sure you have an understanding of Python before you get into Django or Flask. Do this by taking one (or all) of the following online classes: a. Udacity.com: http://www.udacity.com/overview/Course/cs101/CourseRev/apr2012 http://www.udacity.com/overview/Course/cs101/CourseRev/apr20... b. Learnpythonthehardway.org (There are video lessons for a price of $29) c. https://www.edx.org/courses/MITx/6.00x/2012_Fall/about https://www.edx.org/courses/MITx/6.00x/2012_Fall/about 2. Once you have an understanding of python and can write simple scripts, I recommend the following video courses for web development with Python: a. Flask: http://www.youtube.com/user/calicoJake http://www.youtube.com/user/calicoJake (A great Flask video tutorial series) b. Udacity: http://www.udacity.com/overview/Course/cs253/CourseRev/apr2012 http://www.udacity.com/overview/Course/cs253/CourseRev/apr20... (not flask or django, but still good) c. Django: http://www.kickstarter.com/projects/657368266/getting-started-with-django http://www.kickstarter.com/projects/657368266/getting-starte... (to be released in Dec 2012 or early 2013.
- adambard 14y agoDepends what you want to build. Flask is better suited to apps that are a) small and single-purpose, or b) highly nonstandard. Django has a lot of stuff built right in, much of which you won't need. But it's nice to have a database abstraction, forms, auth, admin, etc. when you need them. Plus, it's practically a CMS already all by itself, with the nice admin panel. I'd probably start with Django. The tutorial isn't bad at all: https://docs.djangoproject.com/en/1.4/intro/tutorial01/ https://docs.djangoproject.com/en/1.4/intro/tutorial01/
- GeneralMaximus 14y agoYou can never go wrong with Django. It comes with enough batteries included to get you up and running with complex projects quickly. Plus, there's a lively ecosystem of useful libraries built on top on Django that make complex tasks a breeze. If you want to built useful webapps quickly, Django is the way to go. The assertion that Flask gives you a better look under the hood is, in my opinion, incorrect. With Flask, you get almost nothing out of the box besides some basic URL routing and request handing. For most web development tasks, that's not enough. So you end up adding an ORM, a template engine, a session handling library, etc. on top. Eventually you end up with a set of libraries that have as much "magic" to them as your standard Django install, except now they're loosely held together by duct tape. Just take a look at SQLAlchemy, WTForms or Jinja2 -- three libraries that are often used with Flask -- and tell me whether they feel less like magic than Django's equivalents. Plus, now you have to look up documentation for three libraries in three different places, keep up with their developments separately, and get used to three different coding conventions. It gets complex very fast. As adambard mentioned, Flask is a very effective tool when you want to do something highly nonstandard and rolling your own framework is your only option. For 9 out of 10 webapps, though, Django is the right answer.
- veeti 14y agoI agree completely. However, personally I am using Flask only because tacking SQLAlchemy on top of Django feels so hacky. I wish there was a second full stack framework with SA.
- GeneralMaximus 14y agoHave you given Pyramid a look?
- veeti 14y agoThe core Pyramid setup is actually just as minimal as Flask is. You need to add a million different Pyramid_ addons to get "full stack" functionality.
- devb0x 14y agoYou could start tonight. Master your art, choose your weapon - django or flask - and hit the ground running. oh and have fun.
- expralitemonk 14y agoI started learning Django as my first web framework. If I had to do it over I would have spent a month with Flask, and then moved to Django. Django is a big app, and I found it difficult to build a mental model of its workings. Maybe starting with a smaller framework would have made it easier.
- sejje 14y agoI think if you end up in development as a career, Django is going to be used incredibly more often than Flask. In the end, you will learn the internals either way. If you start with Flask, you'll still have to learn about Django internals. Start with Django (and you'll probably never switch to Flask).
- sejje 14y agoAnd to answer your last question--I'd think assuming fast learner, and you're already competent with python, I'd think a few days and you can have up a basic app (blog, wiki, something like that), and a few weeks and you'll be pretty comfortable with any normal CRUD app.