-
Notifications
You must be signed in to change notification settings - Fork 30
Emincan Yazgi Homework4 #100
base: main
Are you sure you want to change the base?
Conversation
upy
left a comment
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.
var olan migration dosyalarina ozel durumlar haric dokunmamayi tercih ediyoruz.
| @@ -1,6 +1,5 @@ | |||
| # Generated by Django 3.2.9 on 2021-12-03 17:37 | |||
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.
migration dosyalarina dokunmamaliyiz.
| existing_basket_item.quantity += quantity | ||
| existing_basket_item.save() | ||
| else: | ||
| new_basket_item = BasketItem(basket=basket, product=product, quantity=quantity, price=price) |
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.
model objelerini kullanmak yerine serializerlari kullanmak daha iyi fikir.
| def create(self, validated_data): | ||
| password = validated_data.pop("password", None) | ||
| password_repeat = validated_data.pop("password_repeat", None) | ||
| instance = self.Meta.model(**validated_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.
manager'imizda create_user seklinde guzel bir methodumuz var.
| class Meta: | ||
| model = Customer | ||
| fields = ("email", "password", "password_repeat") | ||
| extra_kwargs = {"password": {"write_only": True}, "password_repeat": {"write_only": True}} |
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.
yukarida tanimladigimiz bir field oldugundan buraya koymamizin bir anlami olmuyor. (password_repeat)
| return queryset.filter(customer=user) | ||
|
|
||
| @action(detail=True, methods=['post', 'put']) | ||
| def add_to_basket(self, request, pk=None): |
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.
kayit ekleme/guncelleme, valitation islemleri serializer tarafinda yapilmasi 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 soz konusu ise burada problem olusuyor sanki?
Because of the pulling error at the start, even though I shouldn't change the migration files I had to.