Hello!

I tried to use following examples:
https://docs.djangoproject.com/en/dev/topics/class-based-views/mixins/

import jsonfrom django.http import HttpResponseclass JSONResponseMixin(object):
    response_class = HttpResponse
    def render_to_response(self, context, **response_kwargs):
        response_kwargs['content_type'] = 'application/json'
        return self.response_class(
            self.convert_context_to_json(context),
            **response_kwargs
        )
    def convert_context_to_json(self, context):
        return json.dumps(context)


from django.views.generic.detail import SingleObjectTemplateResponseMixinclass 
HybridDetailView(JSONResponseMixin, SingleObjectTemplateResponseMixin, 
BaseDetailView):
    def render_to_response(self, context):
        # Look for a 'format=json' GET argument
        if self.request.GET.get('format','html') == 'json':
            return JSONResponseMixin.render_to_response(self, context)
        else:
            return SingleObjectTemplateResponseMixin.render_to_response(self, 
context)


It seems to me, that attribute response_class = HttpResponse in 
JSONReponseMixin overlaps attribute response_class = TemplateResponse in 
TemplateResponseMixin (and SingleObjectTemplateResponseMixin) and breaks 
non-json requests.

Michal

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to