Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 2.31 KB

settings.rst

File metadata and controls

75 lines (50 loc) · 2.31 KB

Oscar API Settings

Main settings

OSCARAPI_BLOCK_ADMIN_API_ACCESS

Default: True

Useful in production websites wehere you want to make sure that admin users can't access the API (they can read/write anything which is exposed by the API).

Serializer settings

Most of the model serializers in Oscar API have a default set of fields to use in the REST API. If you customized the Oscar models you can reflect this customization by adding settings for this serializer.

For example, the RecommendedProduct serializer is defined as following:

class RecommmendedProductSerializer(OscarModelSerializer):
    url = serializers.HyperlinkedIdentityField(view_name='product-detail')

    class Meta:
        model = Product
        fields = overridable(
            'OSCARAPI_RECOMMENDED_PRODUCT_FIELDS',
            default=('url',)
        )

When you add the following section to your settings.py you will add the 'title' field as well:

OSCARAPI_RECOMMENDED_PRODUCT_FIELDS = ('url', 'title')

The following serializers have customizable field settings:

Basket serializers

oscarapi.serializers.basket.BasketSerializer

oscarapi.serializers.basket.BasketLineSerializer

oscarapi.serializers.basket.VoucherSerializer

Checkout serializers

oscarapi.serializers.checkout.OrderSerializer

oscarapi.serializers.checkout.OrderLineSerializer

oscarapi.serializers.checkout.UserAddressSerializer

Login serializers

oscarapi.serializers.login.UserSerializer

Product serializers

oscarapi.serializers.product.OptionSerializer

oscarapi.serializers.product.ProductLinkSerializer

oscarapi.serializers.product.RecommmendedProductSerializer

oscarapi.serializers.product.ChildProductSerializer

oscarapi.serializers.product.ProductSerializer

oscarapi.serializers.product.ProductAttributeSerializer

oscarapi.serializers.product.ProductAttributeValueSerializer