0
謝謝你的幫助。 我的問題是,由於某種原因,我的代碼不執行我的if語句中的模板:我可以在django的{%statements%}中使用{{stuff}}嗎?
{% if {{game.player}} == {{user.username}} %}
<a href="/game/stop/">Stop this game</a>
{% else %}
current user: {{ user.username }}
game by: {{ game.player }}
{% endif %}
當「其他」語句執行user.username確實= game.player,但由於某些原因,如果語句不執行。我確實在沒有圍繞game.player的{{}}的情況下進行嘗試,並且只是爲了匹配字符串。但它不會工作,我很困惑!
感謝您的時間:) blargie-BLA
我會_guess_'{%如果game.player == user.username%}'將是有效的基於[演示](https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from = olddocs)。 – 2012-01-30 19:11:43
這甚至沒有接近合法使用Django模板引擎。您應該查看https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#if文檔以瞭解如何在if結構中引用變量。然後**根據您閱讀的內容更新**您的問題。 – 2012-01-30 19:13:05
謝謝你們:)我也嘗試過,並沒有工作,但也許還有另一個問題,那麼謝謝你的時間! x – 2012-01-30 20:05:46