Skip to content

ProductWhishList Model

The ProductWhishList model represents a wishlist created by a user for a product on the platform. It includes information about the user, the product, and whether the product is marked as wished by the user.


Fields

Field Type Required Description
user ForeignKey Yes A foreign key to the User model, representing the user who created the wishlist entry.
product ForeignKey Yes A foreign key to the Product model, representing the product added to the wishlist.
is_wished BooleanField No A boolean indicating whether the user has wished for the product (default: False).
created_at DateTimeField Yes Auto-generated timestamp indicating when the wishlist entry was created.

Unique Constraints

  • Unique Together: A unique constraint is applied to the combination of user and product. This ensures that a user cannot add the same product to their wishlist more than once.

Custom Methods

  • __str__: This method returns a string representation of the ProductWhishList object, which includes the user's email and the product's name. Example: "{user.email}'s wishlist item: {product.name}".