简体   繁体   中英

How to use Django templatetags in static media files?

Im using a flash gallery and the settings xml file is stored in /media/xml/gallery.xml

In the gallery.xml file I want to add this snippet of code:

<items>
    {% for image in images %}
    <item source="{{ MEDIA_URL }}{{ image.image }}" thumb="" description="{{ image.title }}" />
    {% endfor %}
</item>

But the source="... renders as such: http://127.0.0.1:8000/media/images/gallery/%7B%7B%20MEDIA_URL%20%7D%7D%7B%7B%20image.image%20%7D%7D

Is there a way I can work around this problem? Thanks for the help.

您将必须通过Django视图提供此文档,并将其呈现为模板。

Static media is, by definition, static. If you want Django mechanisms to work then you need to process using Django.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM