Populate with two fields
galileoguzman opened this issue · comments
Hi, I have a question, ¿May I populate AutpSlugField with more than one field? I mean, if I want to generate slug with this model:
class Article(models.Model):
name = models.CharField()
created_at = models.DateField()
slug = AutoSlugField(populate_from=('title', 'created_at'))
This will generate the next slug: 'article-name-2016-08-04'
slug = AutoSlugField(populate_from=lambda instance: "{0}-{1}".format(instance.title, instance.created_at.isocalendar()))
It solves your problem but Django can't generate migration files. So, you need create a separated function instead of lambda function.