Add categories.txt

This commit is contained in:
2025-09-22 08:31:44 +00:00
parent 8f456d6839
commit 469793b5df
3 changed files with 156 additions and 3 deletions

View File

@@ -17,13 +17,13 @@ class Command(BaseCommand):
print("Deleting existing instances")
CategoryTag.objects.all().delete()
file_path = settings.BASE_DIR + '/../datasets/' + settings.TAXONOMY_FILE
file_path = settings.BASE_DIR + '/datasets/' + settings.TAXONOMY_FILE
counter = 0
with open(file_path, 'rt') as data_file:
print(f"Reading from {settings.TAXONOMY_FILE}")
for line in data_file.readlines():
try:
tag = Product.category.tag_model.objects.create(name=line)
tag = Product.category.tag_model.objects.create(name=line, official=True)
counter += 1
print('.', end='')
logging.debug(f"{tag} created from {line}")