[1.7.x] Fixed #22363 -- Correctly serialize `django.utils.datetime_safe` objects.

Thanks to linovia for the report.

Backport of 074d3183d9 from master