def upload_product_file_loc(instance, filename): slug = instance.product.slug id_ = instance.id if id_ is None: Klass = instance.__class__ qs = Klass.objects.all().order_by('-pk') if qs.exists(): id_ = qs.first().id + 1 else: id_ = 0 if not slug: slug = unique_slug_generator(instance.product) location = "product/{slug}/{id}/".format(slug=slug, id=id_) return location + filename
def product_pre_save_receiver(sender,instance,*args,**kwargs): if not instance.slug: instance.slug = unique_slug_generator(instance)
def product_pre_save_reciever(sender, instance, *args, **kwargs): """Create slug value for every empty slug field""" if not instance.slug: instance.slug = unique_slug_generator(instance)
def product_pre_save_reciever(sender, instance, *args, **kwargs): instance.vat = instance.price * decimal.Decimal(0.2) if not instance.slug: instance.slug = unique_slug_generator(instance)