[1.7.x] Replaced urllib/urlparse imports with from django.utils.six.moves.

Backport of 981b864fbd from master