django-oscar / django-oscar-api

RESTful JSON API for django-oscar
Other
363 stars 160 forks source link

Inconsistency between product class and product category #340

Open JulienPalard opened 3 months ago

JulienPalard commented 3 months ago

Currently the product class is serialized as a slug while the product category is serialized as a name.

I patched my ProductSerializer as:

 class ProductSerializer(oscarapi.serializers.product.ProductSerializer):
    product_class = serializers.SlugRelatedField(
        slug_field="name",
        queryset=oscarapi.serializers.product.ProductClass.objects,
        allow_null=True,
    )

so both are exposed as names. I don't know if it's worth a PR as it may break current uses?

JulienPalard commented 3 months ago

Maybe this need a discussion, maybe there's already a consensus on this, but should the API expose slugs or names?

My gut feeling is that it should expose names, as I prefer the i18n to happen server side than client side, but this argument does not weight much...