Open JzwOnly opened 6 years ago
我也遇到了! model里边有DateTimeField就报错。暂时用 '/><' 作为切割符暂时用着
input_html = [ht for ht in super(AdminSplitDateTime, self).render(name, value, attrs).split('/><') if ht != ''] if (len(input_html) > 1): input_html[0] = input_html[0] + "/>" input_html[1] = "<" + input_html[1] 改成这样用
谢谢。解决了呢
大佬们,有点小问题,现在那个按钮只能点击一下,如果你重新换了时间,再从新点击,就没有效果了
@dalei1995 改 el.val(value);
看看。
https://github.com/sshwsfc/xadmin/blob/master/xadmin/static/xadmin/js/xadmin.widget.datetime.js#L67
def render(self, name, value, attrs=None):
# input_html = [ht for ht in super(AdminSplitDateTime, self).render(name, value, attrs).split('\n') if ht != '']
# return input_html
super_render = super().render(name,value,attrs).replace('/>','/>\n')
import re
input_html = [ht for ht in re.split(r'\n+',super_render) if ht != '']
# input_html = [ht for ht in super(AdminSplitDateTime, self).render(name, value, attrs).split('/><') if ht != '']
# if (len(input_html) > 1):
# input_html[0] = input_html[0] + "/>"
# input_html[1] = "<" + input_html[1]
return mark_safe(
'<div class="datetime clearfix"><div class="input-group date bootstrap-datepicker"><span class="input-group-addon"><i class="fa fa-calendar"></i></span>%s'
'<span class="input-group-btn"><button class="btn btn-default" type="button">%s</button></span></div>'
'<div class="input-group time bootstrap-clockpicker"><span class="input-group-addon"><i class="fa fa-clock-o">'
'</i></span>%s<span class="input-group-btn"><button class="btn btn-default" type="button">%s</button></span></div></div>' % (
input_html[0], _(u'Today'), input_html[1], _(u'Now')))
Admin后台 User 打开 会造成小标越界
super(AdminSplitDateTime, self).render()方法 返回的两个input 标签 之间没有\n ,split(‘\n’)无法分割 input_html[1] 下标越界