changes to readme, and addtaxonomy
This commit is contained in:
@@ -4,11 +4,12 @@ from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
|
||||
from core.models import TreeTag
|
||||
from products.models import Product
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
help = 'Load taxonomy terms into Tags'
|
||||
help = 'Load taxonomy terms into Product.tags'
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
|
||||
@@ -22,11 +23,12 @@ class Command(BaseCommand):
|
||||
print(f"Reading from {settings.TAXONOMY_FILE}")
|
||||
for line in data_file.readlines():
|
||||
try:
|
||||
tag = TreeTag.objects.create(name=line)
|
||||
# tag = TreeTag.objects.create(name=line)
|
||||
tag = Product.tags.tag_model.objects.create(name=line)
|
||||
counter += 1
|
||||
print('.', end='')
|
||||
logging.debug(f"{tag} created from {line}")
|
||||
except Exception as e:
|
||||
logging.error(f"{type(e)} while creating tags from {settings.TAXONOMY_FILE}")
|
||||
print(f"\n{counter} new TreeTag instances created")
|
||||
print(f"\nAdded {counter} Tag objects to Product.tags")
|
||||
print('Shutting down\n')
|
||||
|
||||
Reference in New Issue
Block a user