diff --git a/apps/product/management/commands/add_product_tag.py b/apps/product/management/commands/add_product_tag.py index 33c98b6b..589c7a83 100644 --- a/apps/product/management/commands/add_product_tag.py +++ b/apps/product/management/commands/add_product_tag.py @@ -56,10 +56,10 @@ class Command(BaseCommand): def add_type_product_category(self): for c in tqdm(self.product_type_category_sql(), desc='Add type product category'): - types = ProductType.objects.filter(index_name='wine') + type = ProductType.objects.get(index_name='wine') category = TagCategory.objects.get(index_name=c.tag_category) - if types.exists() and category not in types.tag_categories.all(): - types.tag_categories.add(category) + if type and category not in type.tag_categories.all(): + type.tag_categories.add(category) self.stdout.write(self.style.WARNING(f'Add type product category objects.'))