Skip to content

VendorTestimonials Models

Testimonial Model

The Testimonial model stores feedback or reviews given by a vendor about their services. It includes a rating, testimonial content, and the associated vendor.


Fields

Field Type Required Description
vendor ForeignKey Yes A foreign key to the Vendor model, representing the vendor associated with the testimonial.
rating CharField Yes Stores the rating given by the vendor in the testimonial. The choices are 1 to 5 stars.
content TextField Yes The content or body of the testimonial.
created_at DateTimeField Yes Auto-generated timestamp when the testimonial is created.

Custom Methods

  • __str__: This method returns a string representation of the Testimonial object, displaying the vendor's name and the rating (e.g., Testimonial by {vendor} with rating {rating}).

BlogPost Model

The BlogPost model is used to store blog posts related to vendor services or testimonials. It includes a thumbnail image, title, description, and timestamps for creation and updates.


Fields

Field Type Required Description
thumbnail ImageField No Stores an image file for the blog post's thumbnail. Validated by file extension and custom validation.
title CharField Yes The title of the blog post.
description TextField Yes A textual description or content of the blog post.
created_at DateTimeField Yes Auto-generated timestamp when the blog post is created.
updated_at DateTimeField Yes Auto-generated timestamp when the blog post is updated.

Custom Methods

  • __str__: This method returns the string representation of the BlogPost object, which is the title of the blog post (e.g., {title}).

Custom Methods Overview

Both models contain custom methods: - Testimonial has the __str__ method that provides a string representation of the testimonial, including the vendor and rating. - BlogPost has the __str__ method, which returns the title of the blog post.