Fixed #22724 -- Improve SingleObjectMixin.

https://code.djangoproject.com/ticket/22724