I have created a custom inclusion template tag that accepts a single Update
model object.
Template tag:
@register.inclusion_tag('update_line.html')
def update_line(update):
return {'update': update}
update_line.html:
<tr><td class="update">{{ update }}</td><td class="ack">
<img id="update-{{ update.pk }}" class="ack-img" src="{{ STATIC_URL }}img/acknowledge.png" alt="Acknowledge" /></td></tr>
The problem is that {{ STATIC_URL }}
is not available in my inclusion template tag template, even though I am using the django.core.context_processors.static
context processor so {{ STATIC_URL }}
is available to all of my 'normal' templates that aren't being processed through an inclusion template tag.
Is there a way I can get the STATIC_URL
from within my inclusion template tag template without doing something nasty like manually getting it from settings and explicitly passing it as a context variable?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…