【发布时间】:2016-03-22 06:52:06
【问题描述】:
我的网页中有一个标题,该标题中有一个徽标。我想在该徽标中插入一个锚标记,该标记指向我的主页,即 index.html 页面,尽管调用了哪个视图或页面。我创建了一个base.html,其中的一个sn-p是:
<div class="header">
<div class="inner_header">
<div class="logo">
<a href='#'><img src="{% static 'images/logo.png' %}" alt="logo" /> </a>
</div>
我已将此 base.html 扩展到我的所有其他模板文件
指向我的索引页面和其他页面的 url 模式是这样的:
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^category/(?P<category_name_slug>[\w\-]+)/$', views.category, name='category'),
url(r'^latest/(?P<latest_title_slug>[\w\-]+)/$', views.latest, name='latest'),
url(r'^headline/(?P<heading_title_slug>[\w\-]+)/$', views.headline, name='headline'),)
我尝试过使用<a href="index.html">,<a href=''> 和其他一些不会产生预期结果或出错的东西。在不编写大量代码的情况下执行此操作的适当方法是什么?
【问题讨论】:
-
你试过了吗:
<a href="{% url 'index' %}">? -
href=#不指向不同的页面,例如在索引中,它只是一个空书签。 -
感谢@RohitJain 帮助
标签: python django django-templates django-urls