diff --git a/app/apps/api/serializers/transactions.py b/app/apps/api/serializers/transactions.py index 625a0fd..bacf55a 100644 --- a/app/apps/api/serializers/transactions.py +++ b/app/apps/api/serializers/transactions.py @@ -176,7 +176,7 @@ class TransactionSerializer(serializers.ModelSerializer): ] def __init__(self, *args, **kwargs): - super().__init__(**kwargs) + super().__init__(*args, **kwargs) self.fields["account_id"].queryset = Account.objects.all() diff --git a/app/apps/api/views/accounts.py b/app/apps/api/views/accounts.py index aa1fe00..b5c0fba 100644 --- a/app/apps/api/views/accounts.py +++ b/app/apps/api/views/accounts.py @@ -20,6 +20,8 @@ class AccountViewSet(viewsets.ModelViewSet): pagination_class = CustomPageNumberPagination def get_queryset(self): - return Account.objects.all().select_related( - "group", "currency", "exchange_currency" + return ( + Account.objects.all() + .order_by("id") + .select_related("group", "currency", "exchange_currency") ) diff --git a/app/apps/api/views/transactions.py b/app/apps/api/views/transactions.py index 20b2a82..d3d214a 100644 --- a/app/apps/api/views/transactions.py +++ b/app/apps/api/views/transactions.py @@ -38,7 +38,7 @@ class TransactionViewSet(viewsets.ModelViewSet): return self.update(request, *args, **kwargs) def get_queryset(self): - return Transaction.objects.all().order_by("id") + return Transaction.objects.all().order_by("-id") class TransactionCategoryViewSet(viewsets.ModelViewSet): @@ -51,7 +51,7 @@ class TransactionCategoryViewSet(viewsets.ModelViewSet): class TransactionTagViewSet(viewsets.ModelViewSet): - queryset = TransactionTag.objects.all().order_by("id") + queryset = TransactionTag.objects.all() serializer_class = TransactionTagSerializer pagination_class = CustomPageNumberPagination @@ -60,7 +60,7 @@ class TransactionTagViewSet(viewsets.ModelViewSet): class TransactionEntityViewSet(viewsets.ModelViewSet): - queryset = TransactionEntity.objects.all().order_by("id") + queryset = TransactionEntity.objects.all() serializer_class = TransactionEntitySerializer pagination_class = CustomPageNumberPagination @@ -69,18 +69,18 @@ class TransactionEntityViewSet(viewsets.ModelViewSet): class InstallmentPlanViewSet(viewsets.ModelViewSet): - queryset = InstallmentPlan.objects.all().order_by("id") + queryset = InstallmentPlan.objects.all() serializer_class = InstallmentPlanSerializer pagination_class = CustomPageNumberPagination def get_queryset(self): - return InstallmentPlan.objects.all().order_by("id") + return InstallmentPlan.objects.all().order_by("-id") class RecurringTransactionViewSet(viewsets.ModelViewSet): - queryset = RecurringTransaction.objects.all().order_by("id") + queryset = RecurringTransaction.objects.all() serializer_class = RecurringTransactionSerializer pagination_class = CustomPageNumberPagination def get_queryset(self): - return RecurringTransaction.objects.all().order_by("id") + return RecurringTransaction.objects.all().order_by("-id")