def result_item(self, obj, field_name, row): item = super(MyListAdminView, self).result_item(obj, field_name, row) if field_name in self.show_my_detail_fields and item.text: data = item.text item.text = '' text, attr = label_for_field(field_name, obj.__class__, model_admin=self, return_attr=True) title = text item.btns.append( '<a data-content="%s" class="details-handler" rel="tooltip" title="%s"><i class="fa fa-info-circle"></i></a>' % (data, title)) if self.list_editable and item.field and item.field.editable and ( field_name in self.list_editable): pk = getattr(obj, obj._meta.pk.attname) field_label = label_for_field(field_name, obj, model_admin=self, return_attr=False) item.wraps.insert(0, '<span class="editable-field">%s</span>') item.btns.append(( '<a class="editable-handler" title="%s" data-editable-field="%s" data-editable-loadurl="%s">' + '<i class="fa fa-edit"></i></a>') % (_(u"Enter %s") % field_label, field_name, self.model_admin_url('patch', pk) + '?fields=' + field_name)) # if field_name not in self.editable_need_fields: # self.editable_need_fields[field_name] = item.field return item
def result_item(self, obj, field_name, row): item = super(MyListAdminView, self).result_item(obj, field_name, row) if field_name in self.show_my_detail_fields and item.text: data = item.text item.text = '' text, attr = label_for_field(field_name, obj.__class__, model_admin=self, return_attr=True ) title = text item.btns.append('<a data-content="%s" class="details-handler" rel="tooltip" title="%s"><i class="fa fa-info-circle"></i></a>' % (data, title)) if self.list_editable and item.field and item.field.editable and (field_name in self.list_editable): pk = getattr(obj, obj._meta.pk.attname) field_label = label_for_field(field_name, obj, model_admin=self, return_attr=False ) item.wraps.insert(0, '<span class="editable-field">%s</span>') item.btns.append(( '<a class="editable-handler" title="%s" data-editable-field="%s" data-editable-loadurl="%s">'+ '<i class="fa fa-edit"></i></a>') % (_(u"Enter %s") % field_label, field_name, self.model_admin_url('patch', pk) + '?fields=' + field_name)) # if field_name not in self.editable_need_fields: # self.editable_need_fields[field_name] = item.field return item
def result_item(self, item, obj, field_name, row): if self.list_editable and item.field and item.field.editable and (field_name in self.list_editable): pk = getattr(obj, obj._meta.pk.attname) form = self._get_form_admin(obj).form_obj if field_name in form.fields: form.prefix = str(pk) field_label = label_for_field(field_name, obj, model_admin=self.admin_view, return_attr=False ) data_attr = { 'name': field_name, 'action': self.admin_view.model_admin_url('patch', pk), 'title': _(u"Enter %s") % field_label, 'field': form[field_name] } item.wraps.insert(0, '<span class="editable-field">%s</span>') item.btns.append(loader.render_to_string( 'xadmin/blocks/editable.html', data_attr)) if field_name not in self.editable_need_fields: self.editable_need_fields[field_name] = item.field return item
def init(self): self.label = label_for_field(self.field_name, self.obj.__class__, model_admin=self.admin_view, return_attr=False) try: f, attr, value = lookup_field(self.field_name, self.obj, self.admin_view) except (AttributeError, ObjectDoesNotExist): self.text else: if f is None: self.allow_tags = getattr(attr, 'allow_tags', False) boolean = getattr(attr, 'boolean', False) if boolean: self.allow_tags = True self.text = boolean_icon(value) else: self.text = smart_unicode(value) else: if isinstance(f.rel, models.ManyToOneRel): self.text = getattr(self.obj, f.name) else: self.text = display_for_field(value, f) self.field = f self.attr = attr self.value = value
def result_item(self, item, obj, field_name, row): if self.browser_details and item.field and ( field_name in self.browser_details.keys()): pk = getattr(obj, obj._meta.pk.attname) field_label = label_for_field(field_name, obj, model_admin=self.admin_view, return_attr=False) item.wraps.insert(0, '<span class="browserable-field">%s</span>') title = self.browser_details.get(field_name, {}).get( 'title', _(u"Details of %s") % field_label) default_load_url = self.admin_view.model_admin_url( 'patch', pk) + '?fields=' + field_name load_url = self.browser_details.get(field_name, {}).get( 'load_url', default_load_url) if load_url != default_load_url: concator = '?' if load_url.find('?') == -1 else '&' load_url = load_url + '/' + concator + 'pk=' + str(pk) item.btns.append(( '<a class="browserable-handler" title="%s" data-browserable-field="%s" data-browserable-loadurl="%s">' + '<i class="fa fa-search"></i></a>') % (title, field_name, load_url)) if field_name not in self.browserable_need_fields: self.browserable_need_fields[field_name] = item.field return item
def init(self): self.label = label_for_field(self.field_name, self.obj.__class__, model_admin=self.admin_view, return_attr=False ) try: f, attr, value = lookup_field( self.field_name, self.obj, self.admin_view) except (AttributeError, ObjectDoesNotExist): self.text else: if f is None: self.allow_tags = getattr(attr, 'allow_tags', False) boolean = getattr(attr, 'boolean', False) if boolean: self.allow_tags = True self.text = boolean_icon(value) else: self.text = smart_unicode(value) else: if isinstance(f.rel, models.ManyToOneRel): self.text = getattr(self.obj, f.name) else: self.text = display_for_field(value, f) self.field = f self.attr = attr self.value = value
def result_item(self, item, obj, field_name, row): if self.list_editable and item.field and item.field.editable and ( field_name in self.list_editable): pk = getattr(obj, obj._meta.pk.attname) form = self._get_form_admin(obj).form_obj if field_name in form.fields: form.prefix = str(pk) field_label = label_for_field(field_name, obj, model_admin=self.admin_view, return_attr=False) data_attr = { 'name': field_name, 'action': self.admin_view.model_admin_url('patch', pk), 'title': _(u"Enter %s") % field_label, 'field': form[field_name] } item.wraps.insert(0, '<span class="editable-field">%s</span>') item.btns.append( loader.render_to_string('xadmin/blocks/editable.html', data_attr)) if field_name not in self.editable_need_fields: self.editable_need_fields[field_name] = item.field return item
def result_item(self, item, obj, field_name, row): if ( self.list_editable and item.field and item.field.editable and (field_name in self.list_editable) ): pk = getattr(obj, obj._meta.pk.attname) field_label = label_for_field( field_name, obj, model_admin=self.admin_view, return_attr=False ) item.wraps.insert(0, '<span class="editable-field">%s</span>') item.btns.append( ( '<a class="editable-handler" title="%s" data-editable-field="%s" data-editable-loadurl="%s">' + '<i class="fa fa-edit"></i></a>' ) % ( _(u"Enter %s") % field_label, field_name, self.admin_view.model_admin_url("patch", pk) + "?fields=" + field_name, ) ) if field_name not in self.editable_need_fields: self.editable_need_fields[field_name] = item.field return item
def get(self, request, name): # type: (object, object) -> object if name not in self.data_charts: return HttpResponseNotFound() self.chart = self.data_charts[name] self.x_field = self.chart['x-field'] y_fields = self.chart['y-field'] self.y_fields = (y_fields, ) if type(y_fields) not in ( list, tuple) else y_fields datas = [{ "data": [], "label": force_text(label_for_field(i, self.model, model_admin=self)) } for i in self.y_fields] self.make_result_list() for obj in self.result_list: xf, attrs, value = lookup_field(self.x_field, obj, self) for i, yfname in enumerate(self.y_fields): yf, yattrs, yv = lookup_field(yfname, obj, self) datas[i]["data"].append((value, yv)) option = { 'series': { 'lines': { 'show': True }, 'points': { 'show': False } }, 'grid': { 'hoverable': True, 'clickable': True } } try: xfield = self.opts.get_field(self.x_field) if type(xfield) in (models.DateTimeField, models.DateField, models.TimeField): option['xaxis'] = {'mode': "time", 'tickLength': 5} if type(xfield) is models.DateField: option['xaxis']['timeformat'] = "%y/%m/%d" elif type(xfield) is models.TimeField: option['xaxis']['timeformat'] = "%H:%M:%S" else: option['xaxis']['timeformat'] = "%y/%m/%d %H:%M:%S" except Exception: pass option.update(self.chart.get('option', {})) content = {'data': datas, 'option': option} result = json.dumps(content, cls=JSONEncoder, ensure_ascii=False) return HttpResponse(result)
def get_model_data(self): self.make_result_list() datas = [{"data": [], "label": label_for_field( i, self.model, model_admin=self)} for i in self.y_fields] for obj in self.result_list: xf, attrs, value = lookup_field(self.x_field, obj, self) for i, yfname in enumerate(self.y_fields): yf, yattrs, yv = lookup_field(yfname, obj, self) datas[i]["data"].append((value, yv))
def result_item(self, item, obj, field_name, row): if self._current_layout == 'thumbnails': if getattr(item.attr, 'is_column', True): item.field_label = label_for_field(field_name, self.model, model_admin=self.admin_view, return_attr=False ) if getattr(item.attr, 'thumbnail_img', False): setattr(item, 'thumbnail_hidden', True) row['thumbnail_img'] = item elif item.is_display_link: setattr(item, 'thumbnail_hidden', True) row['thumbnail_label'] = item return item
def result_item(self, item, obj, field_name, row): if self._current_layout == 'thumbnails': if getattr(item.attr, 'is_column', True): item.field_label = label_for_field(field_name, self.model, model_admin=self.admin_view, return_attr=False) if getattr(item.attr, 'thumbnail_img', False): setattr(item, 'thumbnail_hidden', True) row['thumbnail_img'] = item elif item.is_display_link: setattr(item, 'thumbnail_hidden', True) row['thumbnail_label'] = item return item
def result_item(self, item, obj, field_name, row): if self._current_layout == "thumbnails": if getattr(item.attr, "is_column", True): item.field_label = label_for_field( field_name, self.model, model_admin=self.admin_view, return_attr=False, ) if getattr(item.attr, "thumbnail_img", False): setattr(item, "thumbnail_hidden", True) row["thumbnail_img"] = item elif item.is_display_link: setattr(item, "thumbnail_hidden", True) row["thumbnail_label"] = item return item
def result_item(self, item, obj, field_name, row): if self.list_editable and item.field and item.field.editable and (field_name in self.list_editable): pk = getattr(obj, obj._meta.pk.attname) field_label = label_for_field(field_name, obj, model_admin=self.admin_view, return_attr=False ) item.wraps.insert(0, '<span class="editable-field">%s</span>') item.btns.append(( '<a class="editable-handler" title="%s" data-editable-field="%s" data-editable-loadurl="%s">'+ '<i class="fa fa-edit"></i></a>') % (_(u"Enter %s") % field_label, field_name, self.admin_view.model_admin_url('patch', pk) + '?fields=' + field_name)) if field_name not in self.editable_need_fields: self.editable_need_fields[field_name] = item.field return item
def init(self): self.label = label_for_field(self.field_name, self.obj.__class__, model_admin=self.admin_view, return_attr=False ) try: f, attr, value = lookup_field( self.field_name, self.obj, self.admin_view) except (AttributeError, ObjectDoesNotExist): self.text else: if f is None: self.allow_tags = getattr(attr, 'allow_tags', False) boolean = getattr(attr, 'boolean', False) decimal = getattr(attr, 'decimal', None) if boolean: self.allow_tags = True self.text = boolean_icon(value) elif decimal and value is not None: # removing trailing zeros after . from django.utils import formats value = str(value) if value.rfind('.') != -1: value = value.rstrip('0') decimal_places = len(value) - value.index('.') - 1 else: decimal_places = 0 # show value by format settings self.text = formats.number_format(value, decimal_places) else: self.text = smart_text(value) else: if isinstance(f.rel, models.ManyToOneRel): self.text = getattr(self.obj, f.name) else: self.text = display_for_field(value, f) self.field = f self.attr = attr self.value = value
def result_item(self, item, obj, field_name, row): print('afeiafeiafei1314', item.field) if self.list_printable and item.field and ( field_name in self.list_printable) and '通过' == item.value: pk = getattr(obj, obj._meta.pk.attname) field_label = label_for_field(field_name, obj, model_admin=self.admin_view, return_attr=False) # print('afeiafeiafei1212') # item.wraps.insert(0, '<span class="editable-field">%s</span>') # item.btns.append(( # '<a class="printable-handler" title="%s" data-printable-field="%s" data-printable-loadurl="%s">' + # '<i class="fa fa-print"></i></a>') % # (_(u"Enter %s") % field_label, field_name, self.admin_view.model_admin_url('patch', pk) + '?fields=' + field_name)) opts = obj rel_obj = obj # opts.app_label demo print('1typeof rel_obj', rel_obj, type(rel_obj), obj.id) # import django.contrib.auth.models.User try: # item_res_uri = reverse( # '%s:%s_%s_detail' % (self.admin_site.app_name, # 'demo', opts.model_name), # item.field) item_res_uri = str(obj.id) + '/print' print('item_res_uri', item_res_uri) if item_res_uri: # edit_url = reverse( # '%s:%s_%s_change' % (self.admin_site.app_name, 'demo', opts.model_name), # item.field) edit_url = '1212' item.btns.append( '<a data-res-uri="%s" data-edit-uri="%s" class="details-handler" rel="tooltip" title="%s"><i class="fa fa-print"></i></a>' % (item_res_uri, edit_url, _(u'Details of %s') % str(rel_obj))) except NoReverseMatch: pass if field_name not in self.printable_need_fields: self.printable_need_fields[field_name] = item.field return item
def get(self, request, name): if name not in self.data_charts: return HttpResponseNotFound() self.chart = self.data_charts[name] self.x_field = self.chart['x-field'] y_fields = self.chart['y-field'] self.y_fields = ( y_fields,) if type(y_fields) not in (list, tuple) else y_fields datas = [{"data":[], "label": force_text(label_for_field( i, self.model, model_admin=self))} for i in self.y_fields] self.make_result_list() for obj in self.result_list: xf, attrs, value = lookup_field(self.x_field, obj, self) for i, yfname in enumerate(self.y_fields): yf, yattrs, yv = lookup_field(yfname, obj, self) datas[i]["data"].append((value, yv)) option = {'series': {'lines': {'show': True}, 'points': {'show': False}}, 'grid': {'hoverable': True, 'clickable': True}} try: xfield = self.opts.get_field(self.x_field) if type(xfield) in (models.DateTimeField, models.DateField, models.TimeField): option['xaxis'] = {'mode': "time", 'tickLength': 5} if type(xfield) is models.DateField: option['xaxis']['timeformat'] = "%y/%m/%d" elif type(xfield) is models.TimeField: option['xaxis']['timeformat'] = "%H:%M:%S" else: option['xaxis']['timeformat'] = "%y/%m/%d %H:%M:%S" except Exception: pass option.update(self.chart.get('option', {})) content = {'data': datas, 'option': option} result = json.dumps(content, cls=JSONEncoder, ensure_ascii=False) return HttpResponse(result)
def result_item(self, item, obj, field_name, row): if self.list_editable and item.field and item.field.editable and ( field_name in self.list_editable): pk = getattr(obj, obj._meta.pk.attname) field_label = label_for_field(field_name, obj, model_admin=self.admin_view, return_attr=False) # print('app.ccpa.status',field_name,field_label,item.field,row,obj,item) # print('item.field',item.field,item.value) # if '通过'==item.value: # print('item.value',item.value) # item.wraps.insert(0, '<span class="editable-field">%s</span>') item.wraps.insert(0, '<span class="editable-field">%s</span>') item.btns.append(( '<a class="editable-handler" title="%s" data-editable-field="%s" data-editable-loadurl="%s">' + '<i class="fa fa-edit"></i></a>') % (_(u"Enter %s") % field_label, field_name, self.admin_view.model_admin_url('patch', pk) + '?fields=' + field_name)) if field_name not in self.editable_need_fields: self.editable_need_fields[field_name] = item.field return item
def result_header(self, field_name, row): ordering_field_columns = self.ordering_field_columns item = ResultHeader(field_name, row) text, attr = label_for_field(field_name, self.model, model_admin=self, return_attr=True) item.text = text item.attr = attr if attr and not getattr(attr, "admin_order_field", None): return item # OK, it is sortable if we got this far th_classes = ['sortable'] order_type = '' new_order_type = 'desc' sort_priority = 0 sorted = False # Is it currently being sorted on? if field_name in ordering_field_columns: sorted = True order_type = ordering_field_columns.get(field_name).lower() sort_priority = ordering_field_columns.keys().index(field_name) + 1 th_classes.append('sorted %sending' % order_type) new_order_type = {'asc': 'desc', 'desc': 'asc'}[order_type] # build new ordering param o_list_asc = [] # URL for making this field the primary sort o_list_desc = [] # URL for making this field the primary sort o_list_remove = [] # URL for removing this field from sort o_list_toggle = [] # URL for toggling order type for this field make_qs_param = lambda t, n: ('-' if t == 'desc' else '') + str(n) for j, ot in ordering_field_columns.items(): if j == field_name: # Same column param = make_qs_param(new_order_type, j) # We want clicking on this header to bring the ordering to the # front o_list_asc.insert(0, j) o_list_desc.insert(0, '-' + j) o_list_toggle.append(param) # o_list_remove - omit else: param = make_qs_param(ot, j) o_list_asc.append(param) o_list_desc.append(param) o_list_toggle.append(param) o_list_remove.append(param) if field_name not in ordering_field_columns: o_list_asc.insert(0, field_name) o_list_desc.insert(0, '-' + field_name) item.sorted = sorted item.sortable = True item.ascending = (order_type == "asc") item.sort_priority = sort_priority menus = [ ('asc', o_list_asc, 'caret-up', _(u'Sort ASC')), ('desc', o_list_desc, 'caret-down', _(u'Sort DESC')), ] if sorted: row['num_sorted_fields'] = row['num_sorted_fields'] + 1 menus.append((None, o_list_remove, 'times', _(u'Cancel Sort'))) item.btns.append( '<a class="toggle" href="%s"><i class="fa fa-%s"></i></a>' % (self.get_query_string({ORDER_VAR: '.'.join(o_list_toggle)}), 'sort-up' if order_type == "asc" else 'sort-down')) item.menus.extend([ '<li%s><a href="%s" class="active"><i class="fa fa-%s"></i> %s</a></li>' % ((' class="active"' if sorted and order_type == i[0] else ''), self.get_query_string({ORDER_VAR: '.'.join(i[1])}), i[2], i[3]) for i in menus ]) item.classes.extend(th_classes) return item
def result_header(self, field_name, row): ordering_field_columns = self.ordering_field_columns item = ResultHeader(field_name, row) text, attr = label_for_field(field_name, self.model, model_admin=self, return_attr=True) item.text = text item.attr = attr if attr and not getattr(attr, "admin_order_field", None): return item # OK, it is sortable if we got this far th_classes = ["sortable"] order_type = "" new_order_type = "desc" sort_priority = 0 sorted = False # Is it currently being sorted on? if field_name in ordering_field_columns: sorted = True order_type = ordering_field_columns.get(field_name).lower() arr = ordering_field_columns.keys() if six.PY3: arr = list(arr) sort_priority = arr.index(field_name) + 1 th_classes.append("sorted %sending" % order_type) new_order_type = {"asc": "desc", "desc": "asc"}[order_type] # build new ordering param o_list_asc = [] # URL for making this field the primary sort o_list_desc = [] # URL for making this field the primary sort o_list_remove = [] # URL for removing this field from sort o_list_toggle = [] # URL for toggling order type for this field make_qs_param = lambda t, n: ("-" if t == "desc" else "") + str(n) for j, ot in ordering_field_columns.items(): if j == field_name: # Same column param = make_qs_param(new_order_type, j) # We want clicking on this header to bring the ordering to the # front o_list_asc.insert(0, j) o_list_desc.insert(0, "-" + j) o_list_toggle.append(param) # o_list_remove - omit else: param = make_qs_param(ot, j) o_list_asc.append(param) o_list_desc.append(param) o_list_toggle.append(param) o_list_remove.append(param) if field_name not in ordering_field_columns: o_list_asc.insert(0, field_name) o_list_desc.insert(0, "-" + field_name) item.sorted = sorted item.sortable = True item.ascending = order_type == "asc" item.sort_priority = sort_priority menus = [ ("asc", o_list_asc, "caret-up", _(u"Sort ASC")), ("desc", o_list_desc, "caret-down", _(u"Sort DESC")), ] if sorted: row["num_sorted_fields"] = row["num_sorted_fields"] + 1 menus.append((None, o_list_remove, "times", _(u"Cancel Sort"))) item.btns.append( '<a class="toggle" href="%s"><i class="fa fa-%s"></i></a>' % ( self.get_query_string({ORDER_VAR: ".".join(o_list_toggle) }), "sort-up" if order_type == "asc" else "sort-down", )) item.menus.extend([ '<li%s><a href="%s" class="active"><i class="fa fa-%s"></i> %s</a></li>' % ( (' class="active"' if sorted and order_type == i[0] else ""), self.get_query_string({ORDER_VAR: ".".join(i[1])}), i[2], i[3], ) for i in menus ]) item.classes.extend(th_classes) return item
def result_header(self, field_name, row): ordering_field_columns = self.ordering_field_columns item = ResultHeader(field_name, row) text, attr = label_for_field(field_name, self.model, model_admin=self, return_attr=True ) item.text = text item.attr = attr if attr and not getattr(attr, "admin_order_field", None): return item # OK, it is sortable if we got this far th_classes = ['sortable'] order_type = '' new_order_type = 'desc' sort_priority = 0 sorted = False # Is it currently being sorted on? if field_name in ordering_field_columns: sorted = True order_type = ordering_field_columns.get(field_name).lower() arr = ordering_field_columns.keys() if six.PY3: arr = list(arr) sort_priority = arr.index(field_name) + 1 th_classes.append('sorted %sending' % order_type) new_order_type = {'asc': 'desc', 'desc': 'asc'}[order_type] # build new ordering param o_list_asc = [] # URL for making this field the primary sort o_list_desc = [] # URL for making this field the primary sort o_list_remove = [] # URL for removing this field from sort o_list_toggle = [] # URL for toggling order type for this field make_qs_param = lambda t, n: ('-' if t == 'desc' else '') + str(n) for j, ot in ordering_field_columns.items(): if j == field_name: # Same column param = make_qs_param(new_order_type, j) # We want clicking on this header to bring the ordering to the # front o_list_asc.insert(0, j) o_list_desc.insert(0, '-' + j) o_list_toggle.append(param) # o_list_remove - omit else: param = make_qs_param(ot, j) o_list_asc.append(param) o_list_desc.append(param) o_list_toggle.append(param) o_list_remove.append(param) if field_name not in ordering_field_columns: o_list_asc.insert(0, field_name) o_list_desc.insert(0, '-' + field_name) item.sorted = sorted item.sortable = True item.ascending = (order_type == "asc") item.sort_priority = sort_priority menus = [ ('asc', o_list_asc, 'caret-up', _(u'Sort ASC')), ('desc', o_list_desc, 'caret-down', _(u'Sort DESC')), ] if sorted: row['num_sorted_fields'] = row['num_sorted_fields'] + 1 menus.append((None, o_list_remove, 'times', _(u'Cancel Sort'))) item.btns.append('<a class="toggle" href="%s"><i class="fa fa-%s"></i></a>' % ( self.get_query_string({ORDER_VAR: '.'.join(o_list_toggle)}), 'sort-up' if order_type == "asc" else 'sort-down')) item.menus.extend(['<li%s><a href="%s" class="active"><i class="fa fa-%s"></i> %s</a></li>' % ( (' class="active"' if sorted and order_type == i[ 0] else ''), self.get_query_string({ORDER_VAR: '.'.join(i[1])}), i[2], i[3]) for i in menus]) item.classes.extend(th_classes) return item
def get(self, request, name): if name not in self.data_charts: return HttpResponseNotFound() self.chart = self.data_charts[name] self.x_field = self.chart["x-field"] y_fields = self.chart["y-field"] self.y_fields = (y_fields, ) if type(y_fields) not in ( list, tuple) else y_fields datas = [{ "data": [], "label": force_text(label_for_field(i, self.model, model_admin=self)), } for i in self.y_fields] self.make_result_list() for obj in self.result_list: xf, attrs, value = lookup_field(self.x_field, obj, self) for i, yfname in enumerate(self.y_fields): yf, yattrs, yv = lookup_field(yfname, obj, self) datas[i]["data"].append((value, yv)) option = { "series": { "lines": { "show": True }, "points": { "show": False } }, "grid": { "hoverable": True, "clickable": True }, } try: xfield = self.opts.get_field(self.x_field) if type(xfield) in ( models.DateTimeField, models.DateField, models.TimeField, ): option["xaxis"] = {"mode": "time", "tickLength": 5} if type(xfield) is models.DateField: option["xaxis"]["timeformat"] = "%y/%m/%d" elif type(xfield) is models.TimeField: option["xaxis"]["timeformat"] = "%H:%M:%S" else: option["xaxis"]["timeformat"] = "%y/%m/%d %H:%M:%S" except Exception: pass option.update(self.chart.get("option", {})) content = {"data": datas, "option": option} result = json.dumps(content, cls=JSONEncoder, ensure_ascii=False) return HttpResponse(result)