Skip to content

fixed error in get_message under django 2.2+#9

Open
murray3k wants to merge 1 commit intoViktorStiskala:masterfrom
murray3k:master
Open

fixed error in get_message under django 2.2+#9
murray3k wants to merge 1 commit intoViktorStiskala:masterfrom
murray3k:master

Conversation

@murray3k
Copy link
Copy Markdown

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