hotkit / django-slumber

Slumber is a RESTful data connector that can be used to make proper RESTful data services from Django systems.
Boost Software License 1.0
49 stars 17 forks source link

Create accept header handler #12

Open vernomcrp opened 11 years ago

KayEss commented 11 years ago

I was hoping to get a description of what we're doing here :)

The idea is to try to match the resource types requested by the user agent with the resource types supported by the end point. To start with we'll be looking for JSON, HTML and XML. The initial HTML and XML will be pretty ugly, but we should in fairly short order be able to support template based rendering for both of these using Django's built in templating features. To start with these will only be global options.

A further refinement will allow individual operations to return a set of content types they can support so then you'd be able to write an operation that might return some JSON data when requested using application/json, or return a graph when requested as image/png.

KayEss commented 10 years ago

The first part of this is now in develop. There is a general accept handler that will give HTML, XML or JSON representations of the Python data structure built into the response object.

KayEss commented 10 years ago

This has been improved over the last six months, but it's still not really taken as far as it should be.