【发布时间】:2014-07-13 13:44:27
【问题描述】:
我想将这个变量传递给上下文并渲染它,它包含html标签。
notificacion_string = "<a href = \"{% url \'perfiles:perfil\' actor.usuario.username \'recientes\' %}\" > %s </a> voted on your post" % (notificacion.actor.usuario.username)
如您所见,我已尝试转义 href=" " 中的引号。但我得到这个错误:
%u format: a number is required, not unicode
所以,我猜在评估 "% url .." %() 时会发生错误。我尝试了很多事情都没有成功。
额外信息:
url "pefiles:perfil" 接收两个参数:
url(r'^(?P<username>\w+)/(?P<queryset>\w+)/$',views.perfil, name='perfil'),
参数是用户名和查询集,第一个来自notificacion.actor.usuario.username,第二个是字符串'recientes'。
提前感谢您的帮助。
【问题讨论】:
标签: django url tags escaping quotes