Skip to content

Instantly share code, notes, and snippets.

@olivx
Created January 17, 2019 15:29
Show Gist options
  • Save olivx/5a6793eb35e7ccf1a69019e720adba9c to your computer and use it in GitHub Desktop.
Save olivx/5a6793eb35e7ccf1a69019e720adba9c to your computer and use it in GitHub Desktop.
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode, force_bytes, force_text
urlsafe_base64_encode(force_bytes(user.pk))
user_id = urlsafe_base64_decode(force_text(uidb64))
user = get_object_or_404(get_user_model(), pk=user_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment