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
More like this
- Add custom fields to the built-in Group model by jmoppel 1 month, 1 week ago
- Month / Year SelectDateWidget based on django SelectDateWidget by pierreben 4 months, 3 weeks ago
- Python Django CRUD Example Tutorial by tuts_station 5 months, 1 week ago
- Browser-native date input field by kytta 6 months, 3 weeks ago
- Generate and render HTML Table by LLyaudet 7 months ago