for datas in similar_rows: if(not null_price): attribute = Attribute(product=product) attribute.name = datas[3].string.encode('ascii', 'ignore') attribute.price = decimal.Decimal(get_price(datas)) if attribute.price == 0: try: p = Product.objects.filter(sku=datas[1].string[1:]).get() attribute.price = p.price except: # has_valid_prices = False # print "attribute had no previous price, sku = " + datas[1].string[1:] products_not_added.append(datas[1].string[1:]) null_price = True attribute.sku = datas[1].string[1:] attribute.description = datas[5].string attribute.short_description = datas[11].string # attributes.append(attribute) if not null_price: attribute.save() else: products_not_added.append(datas[1].string[1:]) # if(has_valid_prices): # product.save() # for attribute in attributes: # attribute.save() # else: # products_not_added_skus.append(product.sku)