diff --git a/backend/clubs/views.py b/backend/clubs/views.py index df519df41..07e02d255 100644 --- a/backend/clubs/views.py +++ b/backend/clubs/views.py @@ -2217,7 +2217,7 @@ def get_serializer_class(self): return EventWriteSerializer return EventSerializer - @action(detail=False, methods=["post"]) + @action(detail=True, methods=["post"]) def cart(self, request, *args, **kwargs): """ Add a certain number of tickets to cart @@ -2245,6 +2245,9 @@ def cart(self, request, *args, **kwargs): count = request.data.get("count") event = Event.objects.get(id=self.get_object().id) cart = Cart.objects.filter(owner=self.request.user).first() + if not cart: + new_cart = Cart(owner=self.request.user) + new_cart.save() # Try to get count unowned ticket of requested type tickets = Ticket.objects.filter(