class Release(models.Model):
def get_author_slug(self, instance):
author = Musician.objects.filter(releases=instance.id)
if len(author) == 1:
return slugify(''.join([str(a) for a in author]))
else:
return slugify('-'.join([str(a) for a in author]))
def get_slug(self, instance):
author = self.get_author_slug(instance)
name = self.get_name_slug()
self.slug_name = slugify(author + '-' + name)
def create_slug_name(sender, instance, created, **kwargs):
if created:
instance.get_slug(instance)
instance.save()
post_save.connect(create_slug_name, sender=Release)
{название релиза}
. Не знаю почему, но вот почему-то в instance нету музыкантов, только название релиза.