def handle()

in server/store/management/commands/generate_testimonials.py [0:0]


    def handle(self, *args, **options):
        count = options["count"] or 5
        if options["product"]:
            products = Product.objects.filter(pk=options["product"])
        else:
            products = Product.objects.all()  # Populate all products if not specified.

        fake = Faker(["en_AU", "fr_FR", "pt_PT"])

        for p in products:
            for _ in range(count):
                t = Testimonial(
                    product_id=p,
                    reviewer_name=fake.first_name(),
                    reviewer_location=f"{fake.city()}, {fake.country()}",
                    rating=randint(1, 5),
                    summary=" ".join(fake.words(3)) + "!",
                    description=fake.paragraph(nb_sentences=3),
                )
                t.save()

        self.stdout.write(
            f"Generated {count} testimonials across {len(products)} products."
        )