鏈接在我django
應用程序的index.html
(我認爲作爲網站的home page
)我給的鏈接發送至不同地點的用戶到達的地點之一,他應該在website.When找到一個鏈接,回到主頁。所以我創建了一個base.html
被所有頁面繼承,包括index.html
。在base.html
中,我提供了這些鏈接。如果模板狀態顯示在Django
base.html文件
...
<a href="{%url archives %}"> Archives </a>
<br/>
<a href="{% url reports %}"> Reports </a>
<br/>
<a href="{% url home %}"> Home </a>
<br/>
..
我的問題是,當我索引頁(家)上,我不想顯示主link.Is這個可能在模板中這樣做,使用{% if %}
的條件? 目前我沒有傳遞任何參數,在視圖中
@login_required
def index(request, template_name):
print 'index()::template=',template_name
return custom_render(request, {},template_name)
def custom_render(request,context,template):
req_context=RequestContext(request,context)
return render_to_response(template,req_context)
我相信OP想要的是'{%if request.path' **!= **'home_url%}' – egor83 2012-03-16 12:47:10
哦,是的,好點 - 我已經更新了答案 – 2012-03-16 12:53:28
聽起來像是一個很好的方法來做到這一點..會嘗試 – 2012-03-16 12:56:07