Choosing Python Web Frameworks: Django and Flask


If you’re getting into Python for the first time, chances are you’ve researched various web frameworks. If not, click on over the Python wiki and start browsing the expansive variety of web frameworks. Go ahead; we’ll wait.

Overwhelming, isn’t it? Do you choose the most popular full-stack frameworks or do research to find what works best for your needs? It’s tough because Python web frameworks can fall anywhere on a spectrum from executing a single-use case to providing every known feature available. With names like Flask, Django, Tornado, Diesel, Pecan, and Falcon—how do you know where to start?

What are Python Frameworks?

Let’s start by making sure we’re all on the same page here. A web framework is a collection, or library, of packages or modules that make your life easier when building scalable, reliable, and maintainable web applications.

They’re common in all programming languages, but each language has one or several frameworks that they need to run. Python has dozens of different frameworks that coders use depending on if they’re working in a full-stack environment or not.

Why Do Web Frameworks Matter?

Frameworks make it easier to reuse code for common HTTP operations.

Basically, these frameworks encapsulate the work that developers have learned over the last twenty years while programming applications and sites. Say goodbye to protocols, sockets, and process thread management.

What are Django and Flask?

Did you ever see Tango & Cash? It’s a buddy cop action film from 1989. No? Ah, well—it wasn’t very good. Saying “Django and Flask” out loud reminded us of that movie. You know what? Tango and Cash is much like Django and Flask. Hear us out.

Tango and Cash are two narcotics detectives from different sides of Los Angeles who approach problems completely differently, but both manage to get the job done. Disciplined and pristine, Ray Tango (Sylvester Stallone) is a put-together police officer—the total package some might say—who is determined to go by the book. Gabriel Cash, on the other hand, (Kurt Russell) is looser, freer, and plays by his own rules. See where we’re going with this? No? Fine. . . moving on.

Django’s Pros and Cons

Django is commonly called a “batteries-included” framework approach—or the “framework for perfectionists with deadlines.”

This means that Django makes it easy for Python developers to dive into web applications quickly without requiring forethought into the app’s infrastructure ahead of time.

Basically, build better web apps, more quickly, with less code. Django is established, has excellent documentation, and a large online community. One blogger said, “Pirates use Flask, the Navy uses Django,” which feels far more descriptive than does our perfunctory Tango & Cash analogy.

Django Pros

  • Well-established software with many plugins
  • Admin area out of the box makes dev and production of CMS very easy
  • ORM support
  • Clear and defined MVC organization
  • Highly customizable
  • Forms framework
  • Simple database management

Django Cons

  • Feels like too much software for small projects
  • Template errors fail silently by default
  • A process only handles a single request at a time
  • Deep learning curve
  • Overwhelming features

Flask’s Pros and Cons

Flask is a relatively young framework, only in use since 2010. Flask is considered more “Pythonic” than Django is simply because Flask web application code is, in most cases, more explicit. Flask is the choice of most beginners due to the lack of roadblocks to getting a simple app up and running.

Flask Pros

  • Extremely flexible
  • Minimalist without sacrificing power
  • Simple to learn and use
  • Routing URLs is easy
  • Small core and easily extensible

Flask Cons

  • Not async-friendly
  • Limited support and documentation
  • Lack of database/ORM/forms
  • Truly limited in features

Why not choose both?

Well-rounded developers are adept with both Django and Flask. A common route is to start building small, fun projects with a simple framework, like Flask, and move on to Django as you begin to grasp the basics. At Coding Dojo, we teach three full stacks—beginning with the full Python stack that covers both Flask and Django in detail.

Learn Python Frameworks at Coding Dojo

Python is one of the most popular coding languages ​​in the world right now for a reason. Thus, we use it heavily here at Coding Dojo in our four coding bootcamps. If you’re hoping to learn Python you have to learn at least some of its frameworks.

That’s where we come in. Enrolling in our coding bootcamp will get you up to speed on the most popular programming language and its frameworks in anywhere from 14 to 32 weeks. Afterwards, you’ll have lifetime access to our career services team who will help you land your first of many tech jobs.



Please enter your comment!
Please enter your name here