1👍
✅
you probably only want to quote long_url and not the whole string
endpoint = 'https://api-ssl.bitly.com/v3/shorten?access_token={0}&longUrl={1}&format=txt'
req = endpoint.format(settings.ACCESS_KEY, urllib.quote(long_url))
return urlopen(req).read()
Source:stackexchange.com