It is valid Django that if HOST is not present it is assumed to be localhost. I propose that if HOST is not present it is assumed to be localhost as the Django docs suggest.
It looks like you're bumping into this issue described in the PR on comment here: python/cpython#3249 (comment) As described in the comment a viable solution could be to monkeypatch ...