Python django.views.generic.detail.SingleObjectMixin() Examples

The following are 1 code examples of django.views.generic.detail.SingleObjectMixin(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.views.generic.detail , or try the search function .
Example #1
Source File: views.py    From django-elasticsearch with MIT License 4 votes vote down vote up
def render_to_response(self, context):
        content = self._get_content()
        if isinstance(content, Model):
            # Note: for some reason django's serializer only eat iterables
            content = [content,]

        json = serializers.serialize('json', content)
        if isinstance(self, SingleObjectMixin):
            json = json[1:-1]  # eww
        return HttpResponse(json, content_type='application/json; charset=utf-8')