Might want to look at https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.http.urlsafe_base64_encode