Skip to content

Product Promotion(discount banner) Serializer

This section outlines the serializers used in the product promotion API. These serializers handle the transformation of data between complex types (e.g., Django models) and Python data types (e.g., JSON), facilitating the representation of data for API requests and responses.


Serializers

  1. Collection Serializer: ProductPromotionSerializer

1. Product Promotion Serializer

Serializer Overview

ProductPromotionSerializer is used to serialize product promotion data. It includes the product promotion's ID, title, description, discount percentage, banner image, thumbnail image, start date, end date, activity status, and timestamps for creation and updates.

Fields

Field Type Description
id integer The unique identifier for the product promotion.
title string The title of the product promotion.
description string A brief description of the promotion.
discount_percent integer The discount percentage offered in the promotion.
banner_image string The URL of the banner image related to the promotion.
thumbnail_image string The URL of the thumbnail image related to the promotion.
start_date string The start date of the promotion in ISO 8601 format.
end_date string The end date of the promotion in ISO 8601 format.
is_active boolean A boolean indicating whether the promotion is active.
created_at string The timestamp of when the promotion was created in ISO 8601 format.
updated_at string The timestamp of when the promotion was last updated in ISO 8601 format.

Example Response

{
  "id": 1,
  "title": "Winter Sale",
  "description": "Up to 50% off on selected winter products.",
  "discount_percent": 50,
  "banner_image": "https://example.com/media/images/winter-sale-banner.jpg",
  "thumbnail_image": "https://example.com/media/images/winter-sale-thumbnail.jpg",
  "start_date": "2024-12-01T00:00:00Z",
  "end_date": "2024-12-31T23:59:59Z",
  "is_active": true,
  "created_at": "2024-11-15T10:00:00Z",
  "updated_at": "2024-11-15T10:00:00Z"
}