Skip to content

Commit

Permalink
Merge pull request #35 from ARYAN-NIKNEZHAD/perf/api-query
Browse files Browse the repository at this point in the history
Update queryset of apis
  • Loading branch information
sepehr-akbarzadeh authored Dec 5, 2024
2 parents 4cc3284 + 778bd27 commit df49b8b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sage_invoice/api/views/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class CategoryViewSet(ErrorHandlingMixin, viewsets.ModelViewSet):
queryset = Category.objects.all()
queryset = Category.objects.prefetch_related("invoices").all()
serializer_class = CategorySerializer
lookup_field = "slug"

Expand Down
2 changes: 1 addition & 1 deletion sage_invoice/api/views/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class ColumnViewSet(viewsets.ModelViewSet):
queryset = Column.objects.all()
queryset = Column.objects.select_related("invoice", "item").all()
serializer_class = ColumnSerializer
lookup_field = "id"
lookup_url_kwarg = "id"
2 changes: 1 addition & 1 deletion sage_invoice/api/views/expense.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class ExpenseViewSet(viewsets.ModelViewSet):
queryset = Expense.objects.all()
queryset = Expense.objects.select_related("invoice").all()
serializer_class = ExpenseSerializer
lookup_field = "id"
lookup_url_kwarg = "id"
4 changes: 3 additions & 1 deletion sage_invoice/api/views/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@


class InvoiceViewSet(ErrorHandlingMixin, viewsets.ModelViewSet):
queryset = Invoice.objects.all()
queryset = Invoice.objects.select_related("category", "expense", "customer").prefetch_related("category__invoices",
"items__invoice", "columns__item"
).all()
serializer_class = InvoiceSerializer
lookup_field = "slug"
versioning_class = HeaderVersioning
Expand Down
2 changes: 1 addition & 1 deletion sage_invoice/api/views/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class ItemViewSet(viewsets.ModelViewSet):
queryset = Item.objects.all()
queryset = Item.objects.select_related("invoice").all()
serializer_class = ItemSerializer
lookup_field = "id"
lookup_url_kwarg = "id"

0 comments on commit df49b8b

Please sign in to comment.