简体   繁体   English

如何在静态媒体文件中使用Django templatetags?

[英]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 我正在使用Flash Gallery,设置xml文件存储在/media/xml/gallery.xml中

In the gallery.xml file I want to add this snippet of code: 我要在gallery.xml文件中添加以下代码段:

<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 但是source =“ ...的呈现方式如下: 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. 如果您希望Django机制起作用,则需要使用Django进行处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django - 如何使用带有多个参数的templatetags过滤器 - Django — how to use templatetags filter with multiple arguments 如何使用django和nginx配置静态和媒体文件? - How to configure static and media files with django and nginx? python django中MEDIA_ROOT(媒体文件)和STATIC_ROOT(静态文件)的真正区别以及如何正确使用它们 - The real difference between MEDIA_ROOT (media files) and STATIC_ROOT (static files) in python django and how to use them correctly 如何同时使用静态文件和媒体 - How to use both static files and media together 如何将django-storages用于媒体和静态文件? - How can I use django-storages for both media and static files? Django:如何使用Jinja 2的第三方app模板标签? - Django : How to use 3rd party app templatetags with Jinja 2? 在django中使用本地服务器上的静态媒体文件 - use static media files from server locally in django Django 1.5中的静态和媒体文件 - Static and Media files in django 1.5 Django django.contrib.staticfiles.templatetags.static 已在 3.0 中删除:如何替换该功能? - Django django.contrib.staticfiles.templatetags.static removed in 3.0: How could I replace the functionality? 如何在 Django 模板中使用引导程序/静态文件 - How to use Bootstrap/static files in Django templates
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM