- July 2, 2009
- json export admin-action admin serialize
- 2 (after 2 ratings)
The Django Admin Action documentation leads you through exporting a queryset to JSON. However exporting from a single model rarely tells the whole story.
Using the CollectObjects class,
export_related_as_json gathers all instances related by foreign keys to what is being exported and exports them as well in a serialization bonanza.
Use it to export Users and you'll get their Profile objects as well!
# admin.py from django.contrib import admin admin.site.add_action(export_related_as_json)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20