xadmin datetime 类型报错 unsupported format characte

  • 定位到错误为xadmin.views.list.py中的
@property
def label(self):
    text = mark_safe(
        self.text) if self.allow_tags else conditional_escape(self.text)
    if force_text(text) == '':
        text = mark_safe(' ')
    for wrap in self.wraps:
         #就是下面这叫抛旳异常
         text = mark_safe(wrap % text)
    return text
  • 试了试print('<a href="/emmm/emm/2019-07-29%2010:00:00/update/">%s</a>' % '2019年7月29日 10:00'), 发现会报错
  • 修改源码
@property
def label(self):
    text = mark_safe(
        self.text) if self.allow_tags else conditional_escape(self.text)
    if force_text(text) == '':
        text = mark_safe('&nbsp;')
    for wrap in self.wraps:
        #改成下面这样
        text = mark_safe(wrap.replace('%s', '{}').format(text))
    return text
  • 奶丝
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务