from django import http
try:
    import json
except:
    import simplejson as json

from django.views.generic.base import TemplateView

class JSONResponseMixin(object):
    def render_to_response(self, context):
        "Returns a JSON response containing 'context' as payload"
        return self.get_json_response(self.convert_context_to_json(context))

    def get_json_response(self, content, **httpresponse_kwargs):
        "Construct an `HttpResponse` object."
        return http.HttpResponse(content,
                                 content_type='application/json',
                                 **httpresponse_kwargs)

    def convert_context_to_json(self, context):
        "Convert the context dictionary into a JSON object"
        # Note: This is *EXTREMELY* naive; in reality, you'll need
        # to do much more complex handling to ensure that arbitrary
        # objects -- such as Django model instances or querysets
        # -- can be serialized as JSON.
        return json.dumps(context)


class HomeView(TemplateView):
    template_name = 'home.html'

    def get_context_data(self, **kwargs):
        context = super(HomeView, self).get_context_data(**kwargs)
        context['foo'] = 'bar'
        return context

@@ -1203,21 +1203,103 @@
 xt%5B'
-foo'%5D = 'bar'
+homepage'%5D = True #this is needed for the template to render a different structure for homepage
 %0A   

add homepage=True to homepage context, see if statement in templates/home.html for why.