django-autoslug icon indicating copy to clipboard operation
django-autoslug copied to clipboard

Feature request: generating slug from multiple fields

Open just-developr-m opened this issue 5 years ago • 3 comments

Like:

slug = AutoSlugField(populate_from=['title', 'model'])

just-developr-m avatar Dec 14 '19 11:12 just-developr-m

Yeah, that would be awesome.

rasulkireev avatar Jun 08 '21 12:06 rasulkireev

You can anyway do it using a callable like (not tested though):

from django.utils.text import slugify

def populate_from(instance):
     return f"{slugify(instance.title)}-{slugify(instance.model)}"

....
slug = AutoSlugField(populate_from=populate_from)

But anyway, I see, this feature would be great to maintain compatibility with AutoSlufField from django-extensions.

eracle avatar Feb 02 '22 15:02 eracle