Javascript Django模板显示\u200e代码
嘿,伙计们,我在尝试修复网页中显示的unicode代码\u200e时,已不再沮丧/筋疲力尽。我想尽了一切办法。这是我的页面的样子,它的数据是从news.google.com上截取的文章,并随时间提交显示在我的页面上(时间提交是到处弹出\u200e的地方) 我将提供我的views.py、我的articles.html(图片中设置为显示所有内容的页面)和header.html(出于任何原因。但这是用于CSS继承的articles.html的父模板)。此外,我研究并知道\u200e是一个从左到右的标记,当我在news.google.com中检查源代码时,它会在时间提交元素中弹出Javascript Django模板显示\u200e代码,javascript,python,django,Javascript,Python,Django,嘿,伙计们,我在尝试修复网页中显示的unicode代码\u200e时,已不再沮丧/筋疲力尽。我想尽了一切办法。这是我的页面的样子,它的数据是从news.google.com上截取的文章,并随时间提交显示在我的页面上(时间提交是到处弹出\u200e的地方) 我将提供我的views.py、我的articles.html(图片中设置为显示所有内容的页面)和header.html(出于任何原因。但这是用于CSS继承的articles.html的父模板)。此外,我研究并知道\u200e是一个从左到右的标
‎
像这样:
<span class="al-attribution-timestamp">‎51 minutes ago‎</span>
articles.html
{% extends "newz/header.html" %}
{% block content %}
<script>
.firstfont (
font-family: serif;
}
</script>
<div class ="row">
<h3 class="btn-primary">These articles are scraped from <strong>news.google.com</strong></h3><br>
<ul class="list-group">
{% for thefinallist in list %}
<div class="col-md-15">
<li class="list-group-item">{{ thefinallist }}
</li>
</div>
{% endfor %}
</div></ul>
{{ list }}
{% endblock %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Sacred Page</title>
<meta charset="utf-8" />
{% load staticfiles %}
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{% static 'newz/css/bootstrap.min.css' %}" type = "text/css"/>
<style type="text/css">
html,
body {
height:100%
}
</style>
</head>
<body class="body" style="background-color:#EEEDFA">
<div class="container-fluid" style="min-height:95%; ">
<div class="row">
<div class="col-sm-2">
<br>
<center>
<img src="{% static 'newz/img/profile.jpg' %}" class="responsive-img" style='max-height:100px;' alt="face">
</center>
</div>
<div class="col-sm-10">
<br>
<center>
<h3><font color="007385">The sacred database</font></h3>
</center>
</div>
</div><hr>
<div class="row">
<div class="col-sm-2">
<br>
<br>
<!-- Great, til you resize. -->
<!--<div class="well bs-sidebar affix" id="sidebar" style="background-color:#E77200">-->
<div class="well bs-sidebar" id="sidebar" style="background-color:#E1DCF5">
<ul class="nav nav-pills nav-stacked">
<li><a href='/'>Home</a></li>
<li><a href='/newz/'>News database</a></li>
<li><a href='/blog/'>Blog</a></li>
<li><a href='/contact/'>Contact</a></li>
</ul>
</div> <!--well bs-sidebar affix-->
</div> <!--col-sm-2-->
<div class="col-sm-10">
<div class='container-fluid'>
<br><br>
<font color="#2E2C2B">
{% block content %}
{% endblock %}
{% block fool %}
{% endblock fool %}
</font>
</div>
</div>
</div>
</div>
<footer>
<div class="container-fluid" style='margin-left:15px'>
<p><a href="#" target="blank">Contact</a> | <a href="#" target="blank">LinkedIn</a> | <a href="#" target="blank">Twitter</a> | <a href="#" target="blank">Google+</a></p>
</div>
</footer>
</body>
</html>
{%extensed“newz/header.html”%}
{%block content%}
.firstfont(
字体系列:衬线;
}
这些文章摘自news.google.com
{列表%中最后一个列表的%s}
- {{thefinallist}
{%endfor%}
{{list}}
{%endblock%}
header.html
{% extends "newz/header.html" %}
{% block content %}
<script>
.firstfont (
font-family: serif;
}
</script>
<div class ="row">
<h3 class="btn-primary">These articles are scraped from <strong>news.google.com</strong></h3><br>
<ul class="list-group">
{% for thefinallist in list %}
<div class="col-md-15">
<li class="list-group-item">{{ thefinallist }}
</li>
</div>
{% endfor %}
</div></ul>
{{ list }}
{% endblock %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Sacred Page</title>
<meta charset="utf-8" />
{% load staticfiles %}
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{% static 'newz/css/bootstrap.min.css' %}" type = "text/css"/>
<style type="text/css">
html,
body {
height:100%
}
</style>
</head>
<body class="body" style="background-color:#EEEDFA">
<div class="container-fluid" style="min-height:95%; ">
<div class="row">
<div class="col-sm-2">
<br>
<center>
<img src="{% static 'newz/img/profile.jpg' %}" class="responsive-img" style='max-height:100px;' alt="face">
</center>
</div>
<div class="col-sm-10">
<br>
<center>
<h3><font color="007385">The sacred database</font></h3>
</center>
</div>
</div><hr>
<div class="row">
<div class="col-sm-2">
<br>
<br>
<!-- Great, til you resize. -->
<!--<div class="well bs-sidebar affix" id="sidebar" style="background-color:#E77200">-->
<div class="well bs-sidebar" id="sidebar" style="background-color:#E1DCF5">
<ul class="nav nav-pills nav-stacked">
<li><a href='/'>Home</a></li>
<li><a href='/newz/'>News database</a></li>
<li><a href='/blog/'>Blog</a></li>
<li><a href='/contact/'>Contact</a></li>
</ul>
</div> <!--well bs-sidebar affix-->
</div> <!--col-sm-2-->
<div class="col-sm-10">
<div class='container-fluid'>
<br><br>
<font color="#2E2C2B">
{% block content %}
{% endblock %}
{% block fool %}
{% endblock fool %}
</font>
</div>
</div>
</div>
</div>
<footer>
<div class="container-fluid" style='margin-left:15px'>
<p><a href="#" target="blank">Contact</a> | <a href="#" target="blank">LinkedIn</a> | <a href="#" target="blank">Twitter</a> | <a href="#" target="blank">Google+</a></p>
</div>
</footer>
</body>
</html>
神圣的一页
{%load staticfiles%}
html,
身体{
身高:100%
}
神圣数据库
{%block content%}
{%endblock%}
{%block-fool%}
{%endblock%}
| | |
如果需要,可以使用replace()
从字符串中删除字符
b = articles_times.text.replace('\u200E', '')
之所以在呈现的html中看到\u200E
而不是&lrm;
,是因为您在模板中包含了元组{{thefinallist}}
。这意味着Python调用元组上的repr()
,您可以看到\u200E
。这还意味着您可以看到括号,例如(“标题”\u200e1小时前”)
如果单独显示元组的元素,则将在模板中获得&lrm;
。例如,可以执行以下操作:
{% for headline, timeago in list %}
<div class="col-md-15">
<li class="list-group-item">{{ headline }} {{ timeago }}
</li>
</div>
{% endfor %}
{%为标题,时间早于列表%}
{{headline}{{timeago}
{%endfor%}
哦,天哪,谢谢你