@csrf_exempt
def edit_vit(request):
    '\n    Edit 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):
                    form = VitForm(request.POST, instance=vit)
                    if form.is_valid():
                        vit = form.save(commit=False)
                        vit.save()
                        return JsonResponse({'status': 'success', 'vit': vit.to_json()}, status=201)
                    else:
                        return JsonResponse({'error': 'No vit body provided'}, status=400)
                else:
                    return JsonResponse({'error': 'You do not have permission to edit 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)
Edit a vit with API
@csrf_exempt
def edit_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):
                    form = VitForm(request.POST, instance=vit)
                    if form.is_valid():
                        vit = form.save(commit=False)
                        vit.save()
                        return JsonResponse({'status': 'success', 'vit': vit.to_json()}, status=201)
                    else:
                        return JsonResponse({'error': 'No vit body provided'}, status=400)
                else:
                    return JsonResponse({'error': 'You do not have permission to edit 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)