Route requests based on the HTTP Accept header in Django

I recently had need to route HTTP requests by the Accept header, in order to have versioned calls for an API. I found a piece of Django middleware that was similar to what I thought I’d need, and I modified it to support Accept header routing. Grab the full http header routing Django middleware and use it to your advantage.