from django.db.models import Q from django.http import HttpResponse from django.shortcuts import render # Create your views here. from dwebsocket import require_websocket from dashboard.models import Points def index_1(request): return render(request, 'dashboard/index.html') def index_2(request): return render(request, 'dashboard/index_2.html') def points_search_by_keywords(request): query_set = Points.objects.filter(deleted=False) keywords = request.GET.get('keyword') if len(keywords) != 0: topten_list = query_set.filter(Q(sn__contains=keywords)) print(str(topten_list)) return render(request, 'dashboard/results_by_keywords.html', {'topten_list': topten_list}) def points_search_by_sn(request): sn = request.GET.get('sn') if len(sn) != 0 : points = Points.objects.get(sn=sn) return render(request,'dashboard/index.html',{'points':points})