Re:Django Rest Framework general model serializer
by whalesalad on Friday January 30, 2015 @12:05PM
(#8972941)
You say "out of the box" but it's not that simple... 'blah blah DateTime is not JSON serializable'
[ Parent
| on HN ]
Re:Django Rest Framework general model serializer
by andybak on Saturday January 31, 2015 @08:55PM
(#8978874)
Just tried it:
from django.core import serializers
print serializers.serialize("json", StockCount.objects.all()[:2])
>> [{"fields": {"timestamp": "1900-01-02T00:00:00Z", "version": 0, "item_instance": null, "item_model": 408, "stock_level": 999, "location": 2}, "model": "stocklevels.stockcount", "pk": 1}, {"fields": {"timestamp": "1900-01-02T00:00:00Z", "version": 0, "item_instance": null, "item_model": 409, "stock_level": 999, "location": 2}, "model": "stocklevels.stockcount", "pk": 2}]