from django.shortcuts import render from dashboard.models import News from django.http import JsonResponse def news_list(request): category = request.GET.get('category','1') news_list = News.objects.filter(type=category) results = [] for o in news_list: result = dict() result['id'] = o.id result['title'] = o.title result['author'] = o.author result['content'] = o.content result['date'] = o.date results.append(result) return JsonResponse(results, safe=False) def news_detail(request): return render(request, 'polls/news_detail.html')