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
- Month / Year SelectDateWidget based on django SelectDateWidget by pierreben 2 weeks, 6 days ago
- Python Django CRUD Example Tutorial by tuts_station 1 month ago
- Browser-native date input field by kytta 2 months, 2 weeks ago
- Generate and render HTML Table by LLyaudet 2 months, 4 weeks ago
- My firs Snippets by GutemaG 3 months ago