feat: button on/off products

This commit is contained in:
2024-12-29 20:02:51 -03:00
parent ac87c3a47d
commit 9cc0c72f10
17 changed files with 71 additions and 42 deletions

View File

@@ -18,4 +18,13 @@ def createProduct(request):
product = Product(name=name, description=description, price=price, category=category)
product.save()
return redirect('/products')
# return render(request, 'products.html')
# return render(request, 'products.html')
def onOffProduct(request):
id = request.POST.get('id-product')
product_id = int(id)
product = Product.objects.get(id=product_id)
product.active = not product.active
product.save()
return redirect('products')