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

Conversation

@VeliAliyev
Copy link

No description provided.

@VeliAliyev VeliAliyev changed the title new customer registration enabled, created action add_item in basket view Veli Aliev homework 4 Dec 18, 2021

@action(detail=True, methods=['post'])
def add_item(self, request, pk=None):
serializer = BasketItemSerializer(data=request.data)
Copy link
Owner

Choose a reason for hiding this comment

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

price bilgisini kullanicidan almasak daha iyi olacaktir.


if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
Copy link
Owner

Choose a reason for hiding this comment

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

basket viewset i basket'e ait bir serializer verisi donse daha iyi olacaktir.


def get_queryset(self):
queryset = super().get_queryset()
user = self.request.user
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 kullanici durumu varsa problem olusuyor sanki?

return attrs

def create(self, validated_data):
customer = Customer.objects.create(
Copy link
Owner

Choose a reason for hiding this comment

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

manager'imizda create_user seklinde guzel bir methodumuz var.


class RegisterCustomerView(generics.CreateAPIView):
queryset = Customer.objects.all()
permission_classes = (AllowAny,)
Copy link
Owner

Choose a reason for hiding this comment

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

login olmus bir kullanici bu endpointe ulasmasa iyi olur.

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