On 18 October 2010 01:49, Russell Keith-Magee <russ...@keith-magee.com> wrote:
>
> However, you will note that the topic guide that Andrew prepared has a
> section heading specifically targeted at JSON responses. That section
> isn't written yet, but the idea is to put in a guide on how to handle
> JSON responses as way to point out why template rendering has been
> factored out in the way that it has.
>

I just pushed some changes on my fork. They introduce a bunch of
hooks, so that overriding how response instances are created is
easier. I'm not very happy, with catching Http404 in dispatch(), but I
can't think of a better solution at the moment. I also factored out a
ResponseMixin which now include this hooks. To construct a functional
view, you need to have at least one ResponseMixin in your MRO. Also,
creating a JSONMixin is pretty simple:

class JSONMixin(ResponseMixin):

    def get_response_content(self, context):
        return my_serialization_function(context), "application/json"

How to serialize your data properly is a different matter.

[1]: http://bitbucket.org/lqc/django

PS. Excuse me if this all doesn't make any sense, but i'm kinda half
asleep at 3 am.

-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to