-
Notifications
You must be signed in to change notification settings - Fork 30
Veli Aliev homework 4 #104
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| @action(detail=True, methods=['post']) | ||
| def add_item(self, request, pk=None): | ||
| serializer = BasketItemSerializer(data=request.data) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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,) |
There was a problem hiding this comment.
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.
No description provided.