python - html 中的重定向失败

标签 python html css django

我有一个 html:

{% load staticfiles %}
<div style="margin:0 auto; width:900px">
<ul id="nav">
<li id="notification_li">
<a href="#" id="notificationLink">
<div id="notify"> <img src="{% static "images/notification.png" %}" width="20" height="20" />
{% if unseen_notifications.count > 0 %}
    <span id="notification_count">
    {{unseen_notifications.count}}</span>
{% endif %}
</div></a>
<div id="notificationContainer">
<div id="notificationTitle">Inbox</div>
<div id="notificationsBody">
<a href="/home/">Home</a>
</div>
<div id="notificationFooter"><a href="{% url "ask_question" %}">See All</a></div>
</div>
</li>
</ul>
</div>

这里我在 id“notificationContainer”中有“Home”。当我单击“主页”时,它不会重定向,但会在“notificationContainer”之外重定向。在通知容器内,我愿意放置通知。但它不会重定向。

我的风格:

#notification_li{position:relative}
#notificationContainer {
background-color: #FFF;
border: 1px solid rgba(100, 100, 100, .4);
-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
overflow: visible;
position: absolute;
top: 30px;
margin-left: -170px;
width: 400px;
z-index: 11;
display: none;
}
#notificationContainer:before {
content: '';
display: block;
position: absolute;
width: 0;
height: 0;
border: 10px;
margin-top: -20px;
margin-left: 188px;
}
#notificationTitle {
z-index: 1000;
font-weight: bold;
padding: 8px;
font-size: 15px;
background-color: #ffffff;
width: 384px;
border-bottom: 1px solid #dddddd;
}
#notificationsBody {
padding: 0px 0px 0px 0px !important;
margin: 0px;
min-height:300px;
font-size:14px; 
display: block;
}
#notificationsBody a{ color: #000;}
#notification_count {
padding: 3px 7px 3px 7px;
background: #cc0000;
color: #ffffff;
font-weight: bold;
margin-left: 0px;
border-radius: 20px;
position: absolute;
margin-top: -7px;
font-size: 11px;
}
#notificationFooter {
background-color: #e9eaed;
text-align: center;
font-weight: bold;
padding: 8px;
font-size: 12px;
border-top: 1px solid #dddddd;
}

最佳答案

您需要在 urls.py 中定义一个 URL 如果你想像这样使用它 <a href="{% url "ask_question" %}">然后在您的网址中添加一个名称并像这样使用它 <a href="{% url "home" %}">

如果您的家有景观,那么:

url(r'^people/', "myapp.views.people", name="people"), 

如果它只是一个模板,你可以使用这样的东西:

url(r'^home/',TemplateView.as_view(template_name="homepage.html"), name="home"),

关于python - html 中的重定向失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27539616/

相关文章:

Python 继承 - 名称未定义

javascript - Chart.js 类型错误 : context is null

python - 如何将 jinja2 变量插入到 html 元素的属性中?

Python 数组加法递归

python - 如何在 python 中查找 ARIMA 模型的参数 [p, d, q] 值?

python - 如何检查由带德语变音符号的 QString 表示的路径是否存在?

javascript - 在 d3 js 中切割底部圆弧的矩形

html - 放大 Bootstrap 移动设备

javascript - 如何计算 Facebook graph api cover offset_y to pixel?

html - Bootstrap 3.3.7 下拉菜单不起作用