feat: edit product

This commit is contained in:
2024-12-30 10:46:16 -03:00
parent 9cc0c72f10
commit c9f7b33fde
7 changed files with 66 additions and 12 deletions

View File

@@ -27,4 +27,16 @@ def onOffProduct(request):
product = Product.objects.get(id=product_id)
product.active = not product.active
product.save()
return redirect('products')
def editProduct(request, productId):
# id = request.POST.get('productId')
product_id = productId
product = Product.objects.get(id=product_id)
product.name = request.POST.get('name')
product.description = request.POST.get('description')
product.price = request.POST.get('price')
product.quantity = request.POST.get('qtd')
product.category = Categories.objects.get(id = int(request.POST.get('select-categorie')))
product.save()
return redirect('products')