python-twitter-django-tags
python-twitter-django-tags copied to clipboard
expand_tweet_urls is broken because SetText() doesn't exist any more.
Thanks for this great template filters! These saved me a ton of time having to manually rewrite my old CMS's way of doing this.
There's one game-breaking bug, though: the Status class from python-twitter no longer has a SetText()
method. Instead, you apparently just have to assign to tweet.text
directly.
I replaced the filter with this, and it works great:
@register.filter()
def expand_tweet_urls(tweet):
"""
Replace shortened URLs with long URLs in the twitter status. Should be used before urlize_tweet.
"""
for url in tweet.urls:
tweet.text = tweet.text.replace(
url.url, '<a href="{}" target="_blank">{}</a>'.format(url.expanded_url, url.url)
)
return tweet
This works like a charm!