add product in comanda

This commit is contained in:
2024-12-13 10:48:18 -03:00
parent a3bb7bb674
commit b74d817730
12 changed files with 61 additions and 11 deletions

View File

@@ -0,0 +1,15 @@
from django.shortcuts import render, redirect
from comandas.models import Comanda, ProductComanda
from products.models import Product
def listProduct(request):
product = request.GET.get("search-product")
products = Product.objects.filter(name__icontains=product)
return render(request, "htmx_components/htmx_list_products.html", {"products": products})
def addProduct(request, product_id, comanda_id):
product_comanda = ProductComanda(comanda_id=comanda_id, product_id=product_id)
product_comanda.save()
return render(request, "htmx_components/htmx_add_product.html",)