From d94eb9882cb320dca6ae260825f132e389361b70 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 26 Jan 2021 14:05:39 +0000 Subject: [PATCH] changes to addtestdata --- core/management/commands/addtestdata.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/management/commands/addtestdata.py b/core/management/commands/addtestdata.py index 55f035f..25d93b8 100644 --- a/core/management/commands/addtestdata.py +++ b/core/management/commands/addtestdata.py @@ -1,6 +1,8 @@ import logging import json +import requests + from django.core.management.base import BaseCommand from django.contrib.gis.geos import GEOSGeometry, MultiPolygon @@ -19,6 +21,8 @@ logging.basicConfig( class Command(BaseCommand): + logo_url = "https://picsum.photos/200/300" + def handle(self, *args, **kwargs): print("Creating fake data to populate database") @@ -47,7 +51,18 @@ class Command(BaseCommand): for i in range(100): name = fake.last_name_nonbinary() description = fake.paragraph(nb_sentences=5) - product = ProductFactory(name=name, description=description) + # TODO: apply tags from tag list + + """ + # TODO: add dynamic image to product + response = requests.get(self.logo_url) + if response.status_code == 200: + response.raw.decode_content = True + image = response.raw + else: + image= None + """ + product = ProductFactory(name=name, description=description,) logging.debug(f"New Product {product.name} created") print(".", end = '') print('')