Skip to content

fixed error in get_message under django 2.2+ #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

murray3k
Copy link

urlsafe_base64_encode changed in django 2.2 so we get an exception:
.../env/lib/python3.5/site-packages/shared_session/templatetags/shared_session.py", line 58, in get_message return urlsafe_base64_encode(enc_payload).decode('ascii') AttributeError: 'str' object has no attribute 'decode'

See Django Docs:

urlsafe_base64_encode(s):
Encodes a bytestring to a base64 string for use in URLs, stripping any trailing equal signs.
Changed in Django 2.2:
In older versions, it returns a bytestring instead of a string.

I'm using Django's force_text to fix this issue and keep it backward compatible. Seems to work, tested it in 2.1.8 and 2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant