Calling `encode` here is fine. `django.utils.encoding` has generally been one of the only utils modules with a stable-ish API, but I can't find the relevant list of public modules anymore.