I am getting the following error:
AttributeError: 'str' object has no attribute 'decode'
This is my code:
from django.utils.encoding import force_bytes
from django.utils.http import urlsafe_base64_encode
seld.uid = urlsafe_base64_encode(force_bytes(user.pk)).decode()`
Since Django 2.2, urlsafe_base64_encode returns a string instead of bytes, so you should no longer call the decode method anymore:
seld.uid = urlsafe_base64_encode(force_bytes(user.pk))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With