Done

https://code.djangoproject.com/ticket/20643

M.

Dne neděle, 23. června 2013 20:04:28 UTC+2 Baptiste Mispelon napsal(a):
>
>  Hi,
>
> I believe you're right, this code is incorrect.
> Would you mind opening a ticket for this on 
> https://code.djangoproject.com/newticket ?
>
> Thanks,
> Baptiste
>
> On 06/23/2013 05:29 PM, Michal Sládek wrote:
>  
> 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] <javascript:>.
> To post to this group, send email to [email protected]<javascript:>
> .
> Visit this group at http://groups.google.com/group/django-developers.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>
>
> 

-- 
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