lamby / django-slack

Slack integration for Django, using the templating engine to generate messages
https://django-slack.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
241 stars 57 forks source link

Error in UrllibBackend with Django 2.1 #85

Closed beda42 closed 6 years ago

beda42 commented 6 years ago

Hi there,

I just found that when running with the UrllibBackend under Django 2.1, I get an error when using slack_message

AttributeError: 'bool' object has no attribute 'encode'

This is because the value of the SLACK_AS_USER setting is passed into the django.http.request.urlencode function in its "raw" form and unlike in previous versions of Django, where it got converted into string, Django 2.1 tries to run .encode directly on it.

The fix should be fairly easy - just convert the values into strings before url-encoding, but as there may be unforeseen consequences, I would rather leave it to someone who knows the codebase better.

Best regards Beda

p.s.- If SLACK_AS_USER is set to True than there is a simple workaround by changing this value to string in settings SLACK_AS_USER='True'. Another workaround is to switch to RequestsBackend which does not have this problem.

lamby commented 6 years ago

This is actually an upstream bug so whilst you are strictly correct that "unlike in previous versions of Django", the behaviour has been fixed/reverted:

https://code.djangoproject.com/ticket/29627

Fixed and released in 5.12.1

beda42 commented 6 years ago

Sorry, for that. I should have checked upstream.