From 6cabd233e9cbb6567387ecb36a9acc0e7b85b6cc Mon Sep 17 00:00:00 2001 From: root Date: Sat, 11 Nov 2017 14:09:22 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E4=BF=AE=E5=A4=8Dwrap=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E8=BD=AC=E4=B9=89=EF=BC=8C=E6=8A=A5=E9=94=99?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=93=BE=E6=8E=A5=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=B8=8D=E5=B1=95=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xadmin/views/list.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xadmin/views/list.py b/xadmin/views/list.py index 43128c8c3..be76cd090 100644 --- a/xadmin/views/list.py +++ b/xadmin/views/list.py @@ -70,8 +70,16 @@ def label(self): self.text) if self.allow_tags else conditional_escape(self.text) if force_text(text) == '': text = mark_safe(' ') + + def rreplace(s, old, new, occurrence): + li = s.rsplit(old, occurrence) + return new.join(li) + # 修复wrap存在中文转义,报错,修改链接内容不展示的问题 for wrap in self.wraps: - text = mark_safe(wrap % text) + if len(wrap.split("%")) > 2: + text = mark_safe(rreplace(wrap, '%s', text, 1)) + else: + text = mark_safe(wrap % text) return text @property