[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 470fe5a1d1
commit 4ba77b9c2f

View File

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