Skip to content

Catalog Application Models Documentation

This document describes the models used in the catalog application, including categories, products, product variants, promotions, and signature collections.


Category Model

The Category model represents a category of products in the catalog. It is hierarchical, allowing categories to have subcategories.

Field Type Required Description
name CharField Yes The name of the category.
slug SlugField No A unique slug generated from the category name.
parent TreeForeignKey No A self-referencing foreign key to allow subcategories.
description TextField No A description of the category.
banner_image ImageField No An optional banner image for the category.
thumbnail_image ImageField No An optional thumbnail image for the category.
created_at DateTimeField Yes Timestamp for when the category was created.
updated_at DateTimeField Yes Timestamp for when the category was last updated.

Custom Methods

  • __str__: Returns a string representation of the category and its parent categories in a breadcrumb format.
  • get_category_descendants_recursive: Retrieves all root-level categories.

SignatureCollection Model

The SignatureCollection model represents a collection of products that are grouped together under a signature collection.

Field Type Required Description
name CharField Yes The name of the signature collection.
slug SlugField No A unique slug generated from the collection name.
description TextField No A description of the collection.
image ImageField No An image associated with the collection.
is_active BooleanField Yes Indicates whether the collection is active.
cta_url URLField No A URL for a call-to-action related to the collection.

Custom Methods

  • save: Automatically generates a unique slug for the collection and constructs a call-to-action URL.
  • __str__: Returns the name of the collection.

Brand Model

The Brand model represents a brand associated with products, including details such as name, logo, and approval status.

Fields

Field Type Required Description
name CharField Yes Unique name of the brand.
slug SlugField No URL-friendly identifier (auto-generated if blank).
description TextField No Additional details about the brand.
logo ImageField No Brand logo image (stored in brand/logo/).
website URLField No Official website URL of the brand.
is_approved BooleanField No Indicates if the brand is approved (default: False).
created_at DateTimeField No Timestamp when the brand was created (auto).
updated_at DateTimeField No Timestamp when the brand was last updated (auto).

Behavior

  • The slug is automatically generated from the name if not provided.

String Representation

  • Returns the brand's name.

Fabric Model

The Fabric model represents different types of fabric that can be associated with products.

Fields

Field Type Required Description
name CharField Yes Unique name of the fabric.
slug SlugField No URL-friendly identifier (auto-generated if blank).
description TextField No Additional details about the fabric.
is_approved BooleanField No Indicates if the fabric is approved (default: False).
created_at DateTimeField No Timestamp when the fabric was created (auto).
updated_at DateTimeField No Timestamp when the fabric was last updated (auto).

Behavior

  • The slug is automatically generated from the name if not provided.

String Representation

  • Returns the fabric's name.

Product Model

The Product model represents an individual product in the catalog.

Field Type Required Description
name CharField(max_length=1000) Yes The name of the product.
slug SlugField(max_length=1000) No The unique slug for the product.
vendor ForeignKey(Vendor) Yes The vendor associated with the product.
shop ForeignKey(Shop) No The shop associated with the product.
description TextField No A description of the product.
collection ForeignKey(SignatureCollection) No The collection the product belongs to.
discount_percent DecimalField(max_digits=5, decimal_places=2) Yes Discount percentage applied to the product.
category ForeignKey(Category) Yes The category the product belongs to.
video FileField No Product video file.
is_featured BooleanField Yes Whether the product is featured.
is_active BooleanField Yes Whether the product is active.
created_at DateTimeField Yes Timestamp when the product was created.
updated_at DateTimeField Yes Timestamp when the product was last updated.
brand ForeignKey(Brand) No The brand associated with the product.
fabric ForeignKey(Fabric) No The fabric associated with the product.
product_specification TextField No Product specifications.
additional_information TextField No Additional information about the product.
detailed_product_description TextField No Detailed product description.
status ForeignKey(ProductStatus) No Product status (e.g., approved, rejected).
comment TextField No Comment explaining product status.
popularity IntegerField Yes Popularity score of the product.
is_customizable BooleanField Yes Whether the product is customizable.
customized_price DecimalField(max_digits=10, decimal_places=2) No Customized price for the product.
measurement_fields ManyToManyField(MeasurementField) No Fields related to product measurements.

Custom Methods

  • save: Automatically generates a slug from the product name and sets default values for brand and fabric.
  • average_rating: Returns the average rating for the product.
  • total_reviews: Returns the total number of reviews for the product.
  • rating_summary: Returns a summary of the rating counts for the product.
  • create_rejection_notification: Creates a rejection notification when a product is rejected.

ProductImage Model

The ProductImage model represents an image associated with a product, which may have multiple variants.

Field Type Required Description
product ForeignKey Yes Foreign key to the Product model.
variant ForeignKey No Foreign key to the ProductVariant model.
image ImageField No The image associated with the product or variant.
is_primary BooleanField Yes Indicates whether this is the primary image for the product or variant.
created_at DateTimeField Yes Timestamp for when the image was created.

Custom Methods

  • save: Ensures that only one primary image exists per variant.

ProductSize Model

The ProductSize model represents the available sizes for a product.

Field Type Required Description
size CharField Yes The size of the product (e.g., Small, Medium, Large).
value CharField No The specific value for the size (e.g., 32", 34", etc.).
created_at DateTimeField Yes Timestamp for when the size was created.
updated_at DateTimeField Yes Timestamp for when the size was last updated.

Color Model

The Color model represents different colors that can be associated with products.

Fields

Field Type Required Description
name CharField Yes Unique name of the color.
hex_code CharField No Hexadecimal code of the color (e.g., #FFFFFF).
created_at DateTimeField No Timestamp when the color was created (auto).
updated_at DateTimeField No Timestamp when the color was last updated (auto).

String Representation

  • Returns the color's name.

ProductVariant Model

The ProductVariant model represents a variant of a product, such as different colors or sizes.

Field Type Required Description
product ForeignKey Yes Foreign key to the Product model.
color CharField Yes The color of the product variant.
value CharField Yes A value specific to the variant (e.g., a unique identifier).
size ForeignKey No Foreign key to the ProductSize model.
variant_price DecimalField Yes The price of the product variant.
stock_quantity PositiveInteger Yes The stock quantity available for this variant.
is_available BooleanField Yes Indicates whether the variant is available for purchase.
is_active BooleanField Yes Indicates whether the variant is active.
created_at DateTimeField Yes Timestamp for when the variant was created.
updated_at DateTimeField Yes Timestamp for when the variant was last updated.

CategoryPromotion Model

The CategoryPromotion model represents a promotional campaign for a category.

Field Type Required Description
title CharField Yes The title of the promotion.
description TextField No The description of the promotion.
banner_image ImageField No Banner image for the promotion.
thumbnail_image ImageField No Thumbnail image for the promotion.
start_date DateTimeField No The start date of the promotion.
end_date DateTimeField No The end date of the promotion.
cta_url CharField No URL for the call-to-action button.
is_active BooleanField Yes Whether the promotion is currently active.
created_at DateTimeField Yes Timestamp for when the promotion was created.
updated_at DateTimeField Yes Timestamp for when the promotion was last updated.

ProductPromotion Model

The ProductPromotion model represents a promotional campaign for a specific product.

Field Type Required Description
title CharField Yes The title of the promotion.
description TextField No The description of the promotion.
banner_image ImageField No Banner image for the promotion.
thumbnail_image ImageField No Thumbnail image for the promotion.
start_date DateTimeField No The start date of the promotion.
end_date DateTimeField No The end date of the promotion.
discount_percent DecimalField Yes The discount percentage for the promotion.
cta_url CharField No The cta url for the promotion.
is_active BooleanField Yes Whether the promotion is currently active.
created_at DateTimeField Yes Timestamp for when the promotion was created.
updated_at DateTimeField Yes Timestamp for when the promotion was last updated.