自学做网站要多久,公司部门祝福语,做中介平台网站 需要什么,威海建设集团网站首页最近#xff0c;实际一些简单统计时#xff0c;要到库里去检索数据出来用HIGHCHARTS画图#xff0c; 作一个简单的回照。。 DJANGO用TEMPLATEVIEW来作。专业#xff0c;正规#xff1a;#xff09; class SAView(TemplateView):template_name version/sa_site.htmlpagin…最近实际一些简单统计时要到库里去检索数据出来用HIGHCHARTS画图 作一个简单的回照。。 DJANGO用TEMPLATEVIEW来作。专业正规 class SAView(TemplateView):template_name version/sa_site.htmlpaginate_by 10def get_context_data(self, **kwargs):context super(SAView, self).get_context_data(**kwargs)site_dict {}appcount A.objects.annotate(num_appCount(dv))for app in appcount:if self.request.GET.has_key(date_start) and self.request.GET.has_key(date_end) :date_start self.request.GET[date_start]date_end self.request.GET[date_end]context[days] date_start至date_endapp_qryset app.deployversion_set.filter(add_date__range(date_start, date_end))else:context[days] 所有时间app_qryset app.deployversion_set.all()if app.site_set.all() and app_qryset.count():site_key str(app.site_set.all()[0].name)if site_dict.has_key(site_key):site_dict[site_key] app_qryset.count()else:site_dict[site_key] app_qryset.count()categories site_dict.keys()data site_dict.values()context[now] timezone.now()context[current_page] list-sa-sitecontext[form] SASiteFormcontext[categories] categoriescontext[data] datareturn context 前端JAVASCRIPT的小东东找伟哥作了那个最近一周和一月的东东很好感谢 Date.prototype.Format function(fmt)
{var o {M : this.getMonth()1,d : this.getDate(),h : this.getHours(),m : this.getMinutes(),s : this.getSeconds(),q : Math.floor((this.getMonth()3)/3),S : this.getMilliseconds()};if(/(y)/.test(fmt)){fmt fmt.replace(RegExp.$1, (this.getFullYear()).substr(4 - RegExp.$1.length));}for(var k in o){if(new RegExp(( k )).test(fmt)){fmt fmt.replace(RegExp.$1, (RegExp.$1.length1) ? (o[k]) : ((00 o[k]).substr(( o[k]).length)));}}return fmt;
}$(.search_btn).click(function(){var date_start $(input[namedate_start]).val() || demo;var date_end $(input[namedate_end]).val() || demo;var date_today new Date().Format(yyyy-MM-dd);console.log(date_today);if (date_start date_end) {alert(开始时间大于结束时间请重新选择);return;};if ((date_start date_today) || (date_end date_today)) {alert(开始时间和结束时间不能超过当前时间);return;};console.log(date_start, date_end);var url /sa/site/?date_start date_start date_end date_endconsole.log(url)location.href url});
$(.search_btn_week).click(function(){var current new Date();var utcDate current.setDate(current.getDate()-7);var date_start new Date(utcDate).Format(yyyy-MM-dd);var date_end new Date().Format(yyyy-MM-dd);console.log(date_start, date_end);var url /sa/site/?date_start date_start date_end date_endconsole.log(url)location.href url});
$(.search_btn_month).click(function(){var current new Date();var utcDate current.setDate(current.getDate()-30);var date_start new Date(utcDate).Format(yyyy-MM-dd);var date_end new Date().Format(yyyy-MM-dd);console.log(date_start, date_end);var url /sa/site/?date_start date_start date_end date_endconsole.log(url)location.href url}); Form结合了UIKIT的时间PICKER样式 class SASiteForm(forms.Form):date_start forms.CharField(max_length100,labelu开始日期,widgetforms.TextInput(attrs{class: uk-width-1-6,data-uk-datepicker: {format:YYYY-MM-DD},}),)date_end forms.CharField(max_length100,labelu结束日期,widgetforms.TextInput(attrs{class: uk-width-1-6,data-uk-datepicker: {format:YYYY-MM-DD},}),) AND THEN。。。 转载于:https://www.cnblogs.com/aguncn/p/5130029.html