[svn] Fix mistakes in export admin actions. The python serializer only works on simple objects (lists, dicts etc) and not model instances so nix that part.

This commit is contained in:
substantialnoninfringinguser 2009-05-23 20:46:10 +01:00
parent 02db5a9170
commit 0508ba299c

View File

@ -97,25 +97,18 @@ admin.site.register(ScannedImage)
def export_as_json(modeladmin, request, queryset): def export_as_json(modeladmin, request, queryset):
response = HttpResponse(mimetype="text/json") response = HttpResponse(mimetype="text/json")
response['Content-Disposition'] = 'attachment; filename=troggle_output.xml' response['Content-Disposition'] = 'attachment; filename=troggle_output.json'
serializers.serialize("json", queryset, stream=response) serializers.serialize("json", queryset, stream=response)
return response return response
def export_as_xml(modeladmin, request, queryset): def export_as_xml(modeladmin, request, queryset):
response = HttpResponse(mimetype="text/xml") response = HttpResponse(mimetype="text/xml")
response['Content-Disposition'] = 'attachment; filename=troggle_output.xml' response['Content-Disposition'] = 'attachment; filename=troggle_output.xml'
return response serializers.serialize("xml", queryset, stream=response)
def export_as_python(modeladmin, request, queryset):
response = HttpResponse(mimetype="text/python")
response['Content-Disposition'] = 'attachment; filename=troggle_output.py'
serializers.serialize("json", queryset, stream=response)
return response return response
admin.site.add_action(export_as_xml) admin.site.add_action(export_as_xml)
admin.site.add_action(export_as_json) admin.site.add_action(export_as_json)
admin.site.add_action(export_as_python)
try: try:
mptt.register(Subcave, order_insertion_by=['name']) mptt.register(Subcave, order_insertion_by=['name'])