def get(self, request): recv_data = copy.copy(request.GET) current_page_number = request.GET.get('page') search_field = request.GET.get('search_field') if search_field == None: search_field = 'customer__name__contains' keyword = request.GET.get("keyword") all_enrollment = None if keyword: q = Q() q.children.append([search_field, keyword]) all_enrollment = models.Enrollment.objects.filter(q) else: all_enrollment = models.Enrollment.objects.all() all_enrollment = all_enrollment.filter(delete_status=False) total_count = all_enrollment.count() per_page_count = settings.PER_PAGE_COUNT page_number_show = settings.PAGE_NUMBER_SHOW page_obj = Page(current_page_number, total_count, page_number_show, per_page_count, recv_data) all_enrollment = all_enrollment[page_obj.start_data_number:page_obj. end_data_number] page_html = page_obj.page_html_func() return render( request, 'enrollment_record/show_enrollment_record.html', { "all_enrollment": all_enrollment, "page_html": page_html, "keyword": keyword, 'search_field': search_field })
def get(self, request): recv_data = copy.copy(request.GET) current_page_number = request.GET.get("page") #当前页码 search_field = request.GET.get('search_field') #所搜条件 if search_field == None: search_field = 'qq__contains' keyword = request.GET.get("keyword") all_customers = None message = None if keyword: q = Q() q.children.append([search_field, keyword]) all_customers = models.Customer.objects.filter(q) else: if request.path == reverse('mysite:show_customers'): all_customers = models.Customer.objects.filter( consultant__isnull=True) message = "公有" change_message = "公有客户转私有客户" else: all_customers = models.Customer.objects.filter( consultant__username=request.session.get("username")) message = "私有" change_message = "私有客户转公有客户" total_count = all_customers.count() per_page_count = settings.PER_PAGE_COUNT page_number_show = settings.PAGE_NUMBER_SHOW page_obj = Page(current_page_number, total_count, page_number_show, per_page_count, recv_data) all_customers = all_customers[page_obj.start_data_number:page_obj. end_data_number] page_html = page_obj.page_html_func() return render( request, 'customers/show_customers.html', { 'all_customers': all_customers, "page_html": page_html, "keyword": keyword, 'message': message, 'search_field': search_field })
def get(self, request): recv_data = copy.copy(request.GET) current_page_number = request.GET.get("page") # 当前页码 search_field = request.GET.get('search_field') # 所搜条件 if search_field == None: search_field = 'customer__name__contains' keyword = request.GET.get("keyword") all_records = None print(request.GET.dict()) #获取单个客户的id customer_id = request.GET.get("customer_id") if keyword: q = Q() q.children.append([search_field, keyword]) all_records = models.ConsultRecord.objects.filter(q) else: all_records = models.ConsultRecord.objects.all() all_records = all_records.filter( consultant__username=request.session.get('username'), delete_status=False) if customer_id: all_records = all_records.filter(customer_id=customer_id) total_count = all_records.count() per_page_count = settings.PER_PAGE_COUNT page_number_show = settings.PAGE_NUMBER_SHOW page_obj = Page(current_page_number, total_count, page_number_show, per_page_count, recv_data) all_records = all_records[page_obj.start_data_number:page_obj. end_data_number] page_html = page_obj.page_html_func() return render( request, 'consult_record/consult_record.html', { 'all_records': all_records, "page_html": page_html, "keyword": keyword, 'search_field': search_field })