Use the DjangoJSONEncoder so that datetime and date are encoded appropriately. Backport of 2926559c from master