Skip to content
This repository was archived by the owner on May 12, 2023. It is now read-only.

Conversation

@ttoygar
Copy link

@ttoygar ttoygar commented Dec 18, 2021

No description provided.


basket = self.get_object()
try:
product = Product.objects.get(id=request.data["product"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request.data'yı serialize edip kullansak daha iyi olabilir.
bu çekleri serializerda yapmış oluruz.

class BasketViewSet(DetailedViewSetMixin, viewsets.ModelViewSet):
# lookup_field = 'basket'
permission_classes = ()
http_method_names = ["get", "delete"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basketi kullaniciya sildirmek guzel bir fikir olmayabilir.

user = self.request.user
basket_items_list = self.get_queryset().filter(
customer__id=user.id).first().basketitem_set.all()
serializer = self.get_serializer(basket_items_list, many=True)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

burada basketitem serializer'inin datasini donmek guzel bir fikir olmayabilir, ilgili viewset kendi modeline ait serializer'i donmesi daha iyi olacaktir.


@action(detail=True, methods=['post'], http_method_names=['post'])
@atomic()
def add_basket_item(self, request, pk=None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tum bu methoddaki kayit islemlerini, validationlari serializer'a yaptirmak daha iyi olacaktir.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants