开发者

Is there a default template for dumping data from a view

I hav开发者_如何学运维e complex models and would like to just 'dump' some querysets to see exactly what they contain from view code.

I tried the generic list_detail (from urls.py) - but it appears to require writing a template.

Is there a way to dump data from a view (like how json is saved) that will work with anything passed?


You could serialize the queryset to XML and then return that in the response. Something like:

from django.core import serializers

def view(request):
    xml = serializers.serialize('xml', FooModel.objects.all())
    response = HttpResponse(xml, mimetype='application/xml')
    return response


Have you looked into the built-in databrowse app?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜