-
Notifications
You must be signed in to change notification settings - Fork 30
aysenuryazicii-homework3 #71
base: main
Are you sure you want to change the base?
Conversation
| serializer = CountrySerializer(data=country, many=True) | ||
| serializer.is_valid(raise_exception=True) | ||
| serializer.save() | ||
| city.categories.add(*serializer.instance) |
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.
city objesinin categories adında bir fieldı yok.
city nin country fieldı zorunlu olduğundan oluşturabilmek için önce country oluşturman gerekli.
|
|
||
| class BankAccountFilter(filters.FilterSet): | ||
| name = filters.CharFilter(label=_("Bank Account Name"), lookup_expr="icontains") | ||
| iban = filters.CharFilter(label=_("Phone"), lookup_expr="iexact") |
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.
label=iban
| def create(self, validated_data): | ||
| bank = validated_data.pop("bank", None) | ||
| bank_account = super().create(validated_data) | ||
| if bank: |
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.
önce bank objesini oluşturman ve bank accounta parametre olarak vermen gerekli.
|
|
||
|
|
||
| class BasketFilter(filters.FilterSet): | ||
| customer = CustomerFilter |
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.
boyle bir kullanimi nereden ogrendik?
| fields = ("id", "name", "country") | ||
|
|
||
| @atomic() | ||
| def create(self, 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.
ProductDetailedSerializer icerisinde ornek olmasi acisindan vermistik, genelde detailed serializerlari sadece veri gostermek icin aliyoruz ve kayit yapmak ve guncellemek icin kullanmiyoruz, ozel durumlar yoksa kayit create/update islemleri icin genel olarak nested olmayan serializer'i kullaniyoruz.
| 'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'] | ||
| 'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'], | ||
| 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', | ||
| 'PAGE_SIZE': 100 |
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.
Page Number Pagination daha iyi olabilir.
No description provided.