def update(request):
    if ('name' in request.POST):
        image_id = request.POST['image_id']
        image_name = request.POST['name']
        image_description = request.POST['description']
        image_type = request.POST['type']
        image = get_object_or_404(Image, pk=image_id)
        image.name = image_name
        image.description = image_description
        image.type = image_type
        image.save()
        messages.info(request, 'Image updated')
        return HttpResponseRedirect('/images/')
    elif ('image_id' in request.POST):
        image_id = request.POST['image_id']
        image = get_object_or_404(Image, pk=image_id)
        messages.info(request, 'Image updated')
        return render(request, 'edit.html', {'image': image})
    else:
        messages.info(request, 'Could not update image! No name or ID found in request!')
        return HttpResponseRedirect('/images/')
def update(request):
    if ('name' in request.POST):
        image_id = request.POST['image_id']
        image_name = request.POST['name']
        image_description = request.POST['description']
        image_type = request.POST['type']
        image = get_object_or_404(Image, pk=image_id)
        image.name = image_name
        image.description = image_description
        image.type = image_type
        image.save()
        messages.info(request, 'Image updated')
        return HttpResponseRedirect('/images/')
    elif ('image_id' in request.POST):
        image_id = request.POST['image_id']
        image = get_object_or_404(Image, pk=image_id)
        messages.info(request, 'Image updated')
        return render(request, 'edit.html', {'image': image})
    else:
        messages.info(request, 'Could not update image! No name or ID found in request!')
        return HttpResponseRedirect('/images/')