我正在尝试在 Django 1.5 中使用音频播放器 Timeside。处理加载播放器的 JavaScript 函数接收这组参数,
加载播放器.js
loadPlayer function (analizerUrl, soundUrl, soundImgSize, itemId, visualizers, CurrentUserName, isStaffOrSuperuser)
在我的模板中是以下处理启动的脚本
{% If item.file %}
loadPlayer('{% url 'item-analyze-xml' item.public_id %}',
"{% url 'item-export' item.public_id,"mp3" %}", undefined, '{{item.id}}', visualizers,
CURRENT_USER_NAME, //undefined if !user.is_authenticated
true); //true because superuser
{% Endif%}
网址配置如下
url(r'^archives/items/download/(?P<public_id>[A-Za-z0-9._-]+)\.(?P<extension>'
+ export_extensions + ')$',
item_view.item_export,
name="item-export"),
url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/analyze/xml/$',
item_view.item_analyze_xml,
name="item-analyze-xml"),
这在 Django 1.4 中有效,尝试更新以在 1.5 版中使用。问题是我不能在这里发送参数 MP3
"{% url 'item-export' item.public_id,"mp3" %}",
视图 item_export 是这样的:
def item_export(self, request, public_id, extension):
当播放器加载时,我收到以下错误:
Could not parse the remainder: ',' from 'pista.public_id,'
在 Django 1.5 上哪个是正确的语法?
使用 name 和 equal 解决了这一步
{% url 'item-export' public_id=item.public_id extension="mp3" %}
似乎它正在工作,但我有一个新错误:
NoReverseMatch at /pista/1/
Reverse for 'item-analyze-xml' with arguments '()' and keyword arguments '{u'public_id': ''}' not found.