Using Django as a Micro-Framework: Hacking on the HTTP handlers and middleware (for fun and profit)

Wednesday 2:20 pm to 3:10 pm, in Salon A-E
Intermediate

About This Talk

Django, being batteries included and all, is meant to big, clumsy, slow. I’m going to show you how use it as a micro-framework.

The pattern we’re looking at is familiar from various places: node (and Express), closer to home with Flask, and even newfangled async players such as Starlette.

They all feature the same kind of things:

  • Light-weight, probably function-based views.
  • Easy URL routing.
  • And middleware that looks like it does magical things.

Well, in Django, we have function-based views — whether or not we we use them — but what about the rest?

Well, MIDDLEWARE, yes, I’ve seen that — but I tend not to touch it.

And easy URL routing? It’s all separate URL files and includes… — Django projects don’t look much like a micro-framework Hello World.

But it doesn’t have to be that way.

We can configure Django with a micro-framework style.

We can look at the middleware, see how they work, and how we can bend them to our will.

From there we can think about optimizing the base request handlers for our use-case, so that our Django app is as fast as we might care to need.

Big? Clumsy? Slow? Nope.

(Oh, and the batteries’ll still be there if we suddenly realize we need ‘em. 🙂)

Presenters

    Photo of

    Carlton Gibson