def update(request): products = shopify.Product.find(limit=50) for product in products: if product.attributes['published_at']: for variant in product.attributes['variants']: sku = Sku(sku=variant.sku, title=product.attributes['title'], variant=variant.title) sku.save() return HttpResponseRedirect("/")
def handle(self, *args, **options): products = shopify.Product.find(limit=50) for product in products: if product.attributes['published_at']: for variant in product.attributes['variants']: sku = Sku(sku=variant.sku, title=product.attributes['title'], variant=variant.title) sku.save() self.stdout.write('Successfully updated the local DB')