[問題] Django template menu 一問

看板Python作者 (Lego)時間10年前 (2015/03/26 17:18), 10年前編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
我現在 有一個 base.html include menu.html 大概是長這樣 -- {# base.html #} <!DOCTYPE html> {% load staticfiles %} <html> <head> <link href="{% static 'bower_components/semantic-ui/dist/semantic.min.css' %}" rel="stylesheet"/> </head> <body> {% include "lalala/menu.html" %} {% block context %} <h1>Hello</h1> {% endblock %} <script src="{% static 'bower_components/jquery/dist/jquery.min.js' %}"></script> <script src="{% static 'bower_components/semantic-ui/dist/semantic.min.js' %}"></script> </body> </html> -- -- {# menu.html #} <div class="ui pointing menu"> <a class="active item"> <i class="home icon"></i> Home </a> <a class="item"> <i class="write icon"></i> Add </a> </div> -- 我的問題是我之後 index.html extends base.html add.html extends base.html 我希望 menu.html 中的 class="active item" 可以依我不一樣的檔案 active不同的按鈕 index.html是 <a class="active item"> <i class="home icon"></i> Home </a> add.html是 <a class="active item"> <i class=write icon"></i> Add </a> 我不知道這個判斷該怎寫 懇請大大賜教 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.120.73.126 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1427361531.A.C05.html ※ 編輯: qas612820704 (140.120.73.126), 03/26/2015 17:20:08

03/27 13:22, , 1F
最後朋友建議我用jquery幹就好了 感謝各位!
03/27 13:22, 1F
文章代碼(AID): #1L4yxxm5 (Python)
文章代碼(AID): #1L4yxxm5 (Python)