def init_item(self): self.init_raw_items() self.init_brand_and_category() brand = Brand.objects.first() main = Category.objects(level=1).first() sub = Category.objects(level=2).first() department = DepartmentStore.objects.first() for raw_item in self.raw_items: import_item(department.name, main, sub, brand, raw_item)
def init_brand_and_category(self): Item.drop_collection() Brand.drop_collection() Category.drop_collection() DepartmentStore.drop_collection() department = DepartmentStore(name='Macys') department.save() brand = Brand(name=Name(en='Giani Bernini'), is_approved=True) brand.save() main = Category(name=Name(en="Handbags"), level=1, is_approved=True) main.save() sub = Category(name=Name(en="Satchels"), parent=main, level=2, is_approved=True) sub.save() main.sub_categories.append(sub) main.save()