Django template showing \u200e code
<p>Hey guys I am beyond frustrated/exhausted trying to fix this unicode code \u200e showing in my web page. I tried everything I can think of. Here is what my page looks like, its data scraped articles from news.google.com and shown on my page with the time submission (the time submission is where the \u200e pops up everywhere)
<a href="http://i.imgur.com/lrqmvWG.jpg" rel="nofollow">http://i.imgur.com/lrqmvWG.jpg</a></p>

<p>I am going to provide my <strong>views.py</strong>, my <strong>articles.html</strong> (the page in the picture that is set up to display everything), and <strong>header.html</strong> (for whatever reason. But this is the parent template of articles.html for the CSS inheriting). Also, I researched and know that the \u200e is a left-to-right mark and when I inspect the source in news.google.com, it pops up in the <strong>time submission element</strong> as </p>

<pre><code>&amp;lrm;
</code></pre>

<p>like so:</p>

<pre><code>&lt;span class="al-attribution-timestamp"&gt;&amp;lrm;â51 minutes agoâ&amp;lrm;&lt;/span&gt;
</code></pre>

<p>I tried editing the views.py to encode it using .encode(encoding='ascii','ignore') or utf-8 or iso-8859-8 and a couple other lines of code I found researching deep on google but it still displays \u200e everywhere. I put it in so many different parts of my views.py too even right after the for loop (and right before + after it gets stored as data in the variable "b" and its just not going away. What do I need to do?</p>

<p><strong>Views.py</strong></p>

<pre><code>def articles(request):
""" Grabs the most recent articles from the main news page """
import bs4, requests
list = []
list2 = []
url = 'https://news.google.com/'
r = requests.get(url)
sta = "&amp;lrm;"
try:
    r.raise_for_status() == True
except ValueError:
    print('Something went wrong.')
soup = bs4.BeautifulSoup(r.text, 'html.parser')
for listarticles in soup.find_all('h2', 'esc-lead-article-title'):
    a = listarticles.text
    list.append(a)
for articles_times in soup.find_all('span','al-attribution-timestamp'):
    b = articles_times.text
    list2.append(b)
list = zip(list,list2)

context = {'list':list, 'list2':list2}
return render(request, 'newz/articles.html', context)
</code></pre>

<p><strong>articles.html</strong></p>

<pre><code>    {% extends "newz/header.html" %}

{% block content %}
&lt;script&gt;
    .firstfont (
    font-family: serif;
    }
&lt;/script&gt;


&lt;div class ="row"&gt;
&lt;h3 class="btn-primary"&gt;These articles are scraped from &lt;strong&gt;news.google.com&lt;/strong&gt;&lt;/h3&gt;&lt;br&gt;

&lt;ul class="list-group"&gt;
{% for thefinallist in list %}
   &lt;div class="col-md-15"&gt;
       &lt;li class="list-group-item"&gt;{{ thefinallist }}
       &lt;/li&gt;
   &lt;/div&gt;
{% endfor %}
&lt;/div&gt;&lt;/ul&gt;
{{ list }}
{% endblock %}
</code></pre>

<p><strong>header.html</strong></p>

<pre><code>    &lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;title&gt;Sacred Page&lt;/title&gt;
    &lt;meta charset="utf-8" /&gt;
    {% load staticfiles %}
    &lt;meta name="viewport" content = "width=device-width, initial-scale=1.0"&gt;
    &lt;link rel="stylesheet" href="{% static 'newz/css/bootstrap.min.css' %}" type = "text/css"/&gt;
    &lt;style type="text/css"&gt;
        html,
        body {
          height:100%
        }
    &lt;/style&gt;

&lt;/head&gt;



&lt;body class="body" style="background-color:#EEEDFA"&gt;
    &lt;div class="container-fluid" style="min-height:95%; "&gt;
        &lt;div class="row"&gt;
              &lt;div class="col-sm-2"&gt;
                  &lt;br&gt;
                  &lt;center&gt;
                    &lt;img src="{% static 'newz/img/profile.jpg' %}" class="responsive-img" style='max-height:100px;' alt="face"&gt;
                  &lt;/center&gt;
              &lt;/div&gt;
              &lt;div class="col-sm-10"&gt;
                  &lt;br&gt;
                  &lt;center&gt;
                  &lt;h3&gt;&lt;font color="007385"&gt;The sacred database&lt;/font&gt;&lt;/h3&gt;
                  &lt;/center&gt;
              &lt;/div&gt;
        &lt;/div&gt;&lt;hr&gt;

        &lt;div class="row"&gt;
          &lt;div class="col-sm-2"&gt;
          &lt;br&gt;

          &lt;br&gt;
           &lt;!-- Great, til you resize. --&gt;
            &lt;!--&lt;div class="well bs-sidebar affix" id="sidebar" style="background-color:#E77200"&gt;--&gt;
            &lt;div class="well bs-sidebar" id="sidebar" style="background-color:#E1DCF5"&gt;
              &lt;ul class="nav nav-pills nav-stacked"&gt;
                &lt;li&gt;&lt;a href='/'&gt;Home&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href='/newz/'&gt;News database&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href='/blog/'&gt;Blog&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href='/contact/'&gt;Contact&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/div&gt; &lt;!--well bs-sidebar affix--&gt;
          &lt;/div&gt; &lt;!--col-sm-2--&gt;
          &lt;div class="col-sm-10"&gt;

            &lt;div class='container-fluid'&gt;
            &lt;br&gt;&lt;br&gt;
                &lt;font color="#2E2C2B"&gt;
               {% block content %}
               {% endblock %}
                {% block fool %}
                {% endblock fool %}
                &lt;/font&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;footer&gt;
        &lt;div class="container-fluid" style='margin-left:15px'&gt;
            &lt;p&gt;&lt;a href="#" target="blank"&gt;Contact&lt;/a&gt; | &lt;a href="#" target="blank"&gt;LinkedIn&lt;/a&gt; | &lt;a href="#" target="blank"&gt;Twitter&lt;/a&gt; | &lt;a href="#" target="blank"&gt;Google+&lt;/a&gt;&lt;/p&gt;
        &lt;/div&gt;
    &lt;/footer&gt;

&lt;/body&gt;

&lt;/html&gt;
</code></pre>

<p>If you want, you can use <code>replace()</code> to strip the character from your string.</p>

<pre><code>b = articles_times.text.replace('\u200E', '')
</code></pre>

<p>The reason that you see <code>\u200E</code> in the rendered html instead of <code>&amp;lrm;</code> is that you are including the tuple <code>{{ thefinallist }}</code> in your template. That means Python calls <code>repr()</code> on the tuple, and you see <code>\u200E</code>. It also means you see the parentheses, for example <code>('headline' '\u200e1 hour ago')</code></p>

<p>If you display the elements of the tuple separately, then you will get <code>&amp;lrm;</code> in the template instead. For example, you could do:</p>

<pre><code>{% for headline, timeago in list %}
    &lt;div class="col-md-15"&gt;
        &lt;li class="list-group-item"&gt;{{ headline }} {{ timeago }}
        &lt;/li&gt;
    &lt;/div&gt;
{% endfor %}
</code></pre>

javascript python django