FlashSale Model Documentation
This documentation provides details on the FlashSale model used for managing limited-time sales in the application.
FlashSale Model
The FlashSale model represents a limited-time sale for a product or group of products, offering a discount for a specific period.
Fields
| Field | Type | Required | Description |
|---|---|---|---|
title |
CharField(max_length=255) | Yes | The title of the flash sale. |
description |
TextField | Yes | A detailed description of the flash sale. |
start_time |
DateTimeField | Yes | The start date and time of the flash sale. |
end_time |
DateTimeField | Yes | The end date and time of the flash sale. |
discount_percentage |
DecimalField(max_digits=5, decimal_places=2) | Yes | The discount percentage applied during the flash sale. |
product_info |
TextField | No | Additional information about the products on sale (optional). |
Properties
is_active: Returns whether the flash sale is currently active based on the current date and time.remaining_time: Returns the time remaining until the flash sale ends.
Methods
__str__(): Returns the title of the flash sale, providing a human-readable string representation of the object.
Validation
is_active: The sale is considered active if the current date and time fall between thestart_timeandend_time.