diff --git a/sage_invoice/api/serializers/invoice.py b/sage_invoice/api/serializers/invoice.py index f674cfd..da0593a 100644 --- a/sage_invoice/api/serializers/invoice.py +++ b/sage_invoice/api/serializers/invoice.py @@ -41,6 +41,7 @@ class InvoiceSerializer(serializers.HyperlinkedModelSerializer): child=serializers.DictField(child=serializers.CharField()), required=False ) category = CategorySerializer(read_only=True) + customer_name = serializers.CharField(source="customer.name") items = ItemSerializer(many=True, read_only=True) columns = ColumnSerializer(many=True, read_only=True) expense = ExpenseSerializer(read_only=True) @@ -70,7 +71,7 @@ class Meta: ] extra_kwargs = { "url": {"lookup_field": "slug"}, - "categories": {"lookup_field": "slug"}, + "category": {"lookup_field": "slug"}, "items": {"lookup_field": "id"}, "columns": {"lookup_field": "id"}, "expense": {"lookup_field": "id"}, diff --git a/sage_invoice/api/views/category.py b/sage_invoice/api/views/category.py index 8dc1411..31f4b49 100644 --- a/sage_invoice/api/views/category.py +++ b/sage_invoice/api/views/category.py @@ -9,6 +9,7 @@ class CategoryViewSet(ErrorHandlingMixin, viewsets.ModelViewSet): queryset = Category.objects.all() serializer_class = CategorySerializer + lookup_field = "slug" versioning_class = HeaderVersioning