# views.py
from django.http import JsonResponse
from django.views import View
class CheckoutView(View):
def get(self, request):
products_param = request.GET.get('products', '')
coupon = request.GET.get('coupon', None)
# Parse products
product_quantities = {}
if products_param:
for entry in products_param.split(','):
try:
product_id, quantity = entry.split(':')
product_quantities[product_id] = int(quantity)
except ValueError:
continue # Skip malformed entries
# Build response
response_data = {
'products': product_quantities,
'coupon': coupon if coupon else 'No coupon applied'
}
return JsonResponse(response_data)
# urls.py
from django.urls import path
from .views import CheckoutView
urlpatterns = [
path('checkout/', CheckoutView.as_view(), name='checkout'),
]
top of page
workshop apothecary
Black cardamom opens with a deep, spicy edge, softened by a creamy, velvety finish. This mist lingers close to the skin intimate, addictive, and effortlessly chic.