def getUnseenNotifs(request): jsonSerializer = JSONSerializer() unseenNotifs = get_list_or_404(Message, seen=False) return HttpResponse(jsonSerializer.serialize(unseenNotifs), 'application/json')
def getRecentNotifs(request, n=10): jsonSerializer = JSONSerializer() notifs = Message.objects.all() if len(notifs) >= 10: notifs = notifs[(len(notifs) - 10):] return HttpResponse(jsonSerializer.serialize(notifs), 'application/json')