Oscar API Settings¶
All oscarapi settings are defined in oscarapi.settings.
To set these settings in you django settings.py file, prefix them with
OSCARAPI_. So oscarapi.settings.EXPOSE_USER_DETAILS becomes:
OSCARAPI_EXPOSE_USER_DETAILS
Main settings¶
OSCARAPI_BLOCK_ADMIN_API_ACCESS¶
Default: True
Useful in production websites where you want to make sure that the admin api is not exposed at all.
oscarapi.settings.BLOCK_ADMIN_API_ACCESS
OSCARAPI_EXPOSE_USER_DETAILS¶
Default: False
The Login view (GET) and the owner field in the BasketSerializer and CheckoutSerializer expose user details, like username and email address. With this setting you can enable/disable this behaviour.
OSCARAPI_ENABLE_REGISTRATION¶
Default: False
Enables the register endpoint so it’s possible to create new user accounts.
OSCARAPI_LAZY_REMOTE_FILE_REQUEST_HEADERS¶
Default:
default={
"User-Agent": "django-oscar-api/<version>"
}
Changes the headers for the admin api when downloading images.
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 = settings.RECOMMENDED_PRODUCT_FIELDS
When you add the following section to your settings.py you will add the ‘title’ field as well:
OSCARAPI_RECOMMENDED_PRODUCT_FIELDS = ('url', 'title')
Note that you need to prefix the settings with OSCARAPI_ to make them work
in your django settings file.
The following serializers have customizable field settings:
Basket serializers¶
-
class
oscarapi.serializers.basket.BasketSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]¶
Checkout serializers¶
-
class
oscarapi.serializers.checkout.OrderSerializer(*args, **kwargs)[source]¶ The order serializer tries to have the same kind of structure as the basket. That way the same kind of logic can be used to display the order as the basket in the checkout process.
Login serializers¶
Product serializers¶
-
class
oscarapi.serializers.product.ProductLinkSerializer(*args, **kwargs)[source]¶ Summary serializer for list view, listing all products.
This serializer can be easily made to show any field on
ProductSerializer, just add fields to theOSCARAPI_PRODUCT_FIELDSsetting.
-
class
oscarapi.serializers.product.ChildProductSerializer(*args, **kwargs)[source]¶ Serializer for child products