Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: generating slug from multiple fields #61

Open
just-developr-m opened this issue Dec 14, 2019 · 3 comments
Open

Feature request: generating slug from multiple fields #61

just-developr-m opened this issue Dec 14, 2019 · 3 comments

Comments

@just-developr-m
Copy link

Like:

slug = AutoSlugField(populate_from=['title', 'model'])
@rasulkireev
Copy link

Yeah, that would be awesome.

@eracle
Copy link

eracle commented Feb 2, 2022

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.

@hmesfin
Copy link

hmesfin commented Sep 12, 2024

@eracle solution worked for me. However, I didn't like the idea of putting a method before declaring the field. Instead, I called the method using lazy reference. Worked the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants