def head(self, request, *args, **kwargs): with Session() as s: for t in Thread.gets(s, title=request.GET.get('title')): if t.records >=1: return HttpResponse() break return HttpResponseNotFound()
def get(self, request, *args, **kwargs): threads = [] with Session() as s: result = Thread.gets(s, limit=intOrNone(request.GET.get('limit')), stime=intOrNone(request.GET.get('start_time')), etime=intOrNone(request.GET.get('end_time')), title=request.GET.get('title'), ) for t in result: threads.append({ 'id': int(t.id), 'title': t.title, 'timestamp': int(datetime2timestamp(t.timestamp)), 'records': int(t.records), }) obj = { 'threads': threads } return JsonResponse(obj)