def add_goods(request):
    context = dict()
    if request.method == 'POST':
        form = GoodsForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/goods/%d/redact' % form.instance.pk)
        else:
            return HttpResponse('Форма заполнена неверно')
    else:
        context['form'] = GoodsForm()
    return render(request, 'add-goods.html', context)
def redact_goods(request, goods_id):
    goods = get_object_or_404(Goods, pk=int(goods_id))
    context = {'entity': goods}
    if request.method == 'GET':
        context['form'] = GoodsForm(instance=goods)
        return render(request, 'redact-goods.html', context)
    else:
        form = GoodsForm(request.POST, instance=goods)
        context['form'] = form
        if form.is_valid():
            form.save()
            context['info'] = 'Информация о товаре успешно изменена'
        else:
            context['info'] = 'Форма заполнена неверно'
            return render(request, 'redact-goods.html', context)
        return redirect('get-good', entity_id=goods.pk)