def comment(request): if request.method == 'GET': if 'post' in request.GET: return _returnJSON(Comment.objects.filter(post_id = request.GET['post'])) return _returnJSON(Comment.objects.all()) elif request.method == 'POST': postId = request.POST['postId'] message = request.POST['message'] if postId and message: comment = Comment(post_id = postId, message = message, user = request.user) comment.save() return HttpResponse(JsonResponse(comment.serialize())) else: return HttpResponseBadRequest(JsonResponse({'message':'Please supply the associated status and a message'}))