def serialized(request, queryset, format, mimetype=None):
"""
Serialize queryset in specified format and return via HTTP
Standard mimetype for format can be overridden with provided value
"""
from django.http import HttpResponse
from django.core import serializers
content = serializers.serialize(format, queryset)
if mimetype is None:
if format == 'xml':
mimetype = 'application/xml'
elif format == 'json':
# http://www.ietf.org/rfc/rfc4627.txt
mimetype == 'application/json'
return HttpResponse(content=content, mimetype=mimetype)
This looks like an interesting idea - could you create a new ticket
for it at djangoproject.com, so it doesn't get lost?
Thanks,
Simon G.
On Feb 24, 9:44 am, "dchandek" <david.chandek.st...@duke.edu> wrote:
> FWIW, I didn't see anything like this in the distribution, and it
> might be useful ...
>
> def serialized(request, queryset, format, mimetype=None):
> """
> Serialize queryset in specified format and return via HTTP
> Standard mimetype for format can be overridden with provided value
> """
> from django.http import HttpResponse
> from django.core import serializers
> content = serializers.serialize(format, queryset)
> if mimetype is None:
> if format == 'xml':
> mimetype = 'application/xml'
> elif format == 'json':
> #http://www.ietf.org/rfc/rfc4627.txt