@csrf_exempt
def delete_vit(request):
    '\n    Delete a vit with API\n    '
    user = KeyBackend().authenticate(request)
    if (request.method == 'POST'):
        if request.user.is_authenticated:
            try:
                vit = Vit.objects.get(id=request.POST.get('vit_pk'))
                if (vit.user == request.user):
                    vit.delete()
                    return JsonResponse({'status': 'success'}, status=200)
                else:
                    return JsonResponse({'error': 'You do not have permission to delete this vit'}, status=403)
            except Vit.DoesNotExist:
                return JsonResponse({'error': 'Vit not found'}, status=404)
        else:
            return JsonResponse({'error': 'You must be logged in'}, status=401)
    else:
        return JsonResponse({'error': 'Invalid request'}, status=400)
Delete a vit with API
@csrf_exempt
def delete_vit(request):
    '\n    \n    '
    user = KeyBackend().authenticate(request)
    if (request.method == 'POST'):
        if request.user.is_authenticated:
            try:
                vit = Vit.objects.get(id=request.POST.get('vit_pk'))
                if (vit.user == request.user):
                    vit.delete()
                    return JsonResponse({'status': 'success'}, status=200)
                else:
                    return JsonResponse({'error': 'You do not have permission to delete this vit'}, status=403)
            except Vit.DoesNotExist:
                return JsonResponse({'error': 'Vit not found'}, status=404)
        else:
            return JsonResponse({'error': 'You must be logged in'}, status=401)
    else:
        return JsonResponse({'error': 'Invalid request'}, status=400)