Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
317 B
2
Indexable
Never
@receiver(pre_save, sender=Movie)
def pre_save_movie_receiver(sender, instance, raw, using, **kwargs):
	if instance and not instance.slug:
		slug = slugify(instance.title)
		random_string = generate_random_string()
		instance.slug = slug + "_" + random_string


pre_save.connect(pre_save_movie_receiver, sender=Movie)