source_model.model_content.raw_content.encode('utf-8') seems preferable here, because str will break if the text contains non-ascii chars. We know that the encoding is utf-8 since the text comes from an XML file.