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

Conversation

@eylultuncel
Copy link

No description provided.


def get_queryset(self):
queryset = super().get_queryset()
user_id = self.request.user.id
Copy link
Owner

Choose a reason for hiding this comment

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

login olmamis bir user yoksa, burada bir problem olusuyor sanki?



class BasketViewSet(DetailedViewSetMixin, viewsets.ModelViewSet):
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.

def get_queryset(self):
queryset = super().get_queryset()
user = self.request.user
return queryset.filter(customer=user)
Copy link
Owner

Choose a reason for hiding this comment

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

ayni sekilde login olmamis bir kullanici yoksa problem olusuyor sanki.

quantity = request.data["quantity"]
price = product.price
try:
basket = Basket.objects.get(customer__id=user_id, status="open")
Copy link
Owner

Choose a reason for hiding this comment

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

model objelerini kullanmak yerine serializerlari kullanmak daha iyi fikir.

basket.save()
basket_item.save()

serializer = BasketItemSerializer(basket_item)
Copy link
Owner

Choose a reason for hiding this comment

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

basketviewseti basket'e ait bir serializer'i donmesi daha uyumlu 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.

2 participants