擅长:python、mysql、java
<blockquote>
<p>I have tried this code in my template:</p>
</blockquote>
<p>这种复杂的决策过程具有视图功能。</p>
<p>或者它进入上下文,然后呈现给模板。</p>
<p><a href="https://stackoverflow.com/search?q=%5Bdjango%5D+context">https://stackoverflow.com/search?q=%5Bdjango%5D+context</a></p>
<p><a href="https://stackoverflow.com/questions/2880940/when-to-use-context-processor">When to use context processor</a></p>
<p>在你看来这样做</p>
<pre><code>def my_view( request ):
followup= user.has_perm('followup.add_followup')
# etc.
return render_to_response( template, {'followup':followup,... )
</code></pre>
<p>那么你的模板就是</p>
<pre><code>{% if followup %}
<li><a href="{% url followup-new p.id %}">Log</a></li>
{% endif %}
</code></pre>