On Wednesday 25 January 2017 03:50:12 David wrote:

> I have extended Django's default user model to add a Profile model;
> bio etc.
> 
> I want to slugify the users first_name last_name in profile class, so
> I can search for all X entities written by a specific user in the url
> form:
> 
> /blog/authors/bob-smith

Strike the idea to give admin control over the slug. Instead, use 
django-autoslug[1] 
and make the field not editable. Let autoslug handle conflicts by using sane 
values for 
populate_from and unique_with.

Example (from the docs):
# autoslugify value from a custom callable
# (ex. usage: user profile models)
slug = AutoSlugField(populate_from=lambda instance: 
instance.user.get_full_name())
Which is basically what you try to accomplish in the admin.
-- 
Melvyn Sopacua

--------
[1] https://pypi.python.org/pypi/django-autoslug

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4168936.lCcRqWo2Xk%40devstation.
For more options, visit https://groups.google.com/d/optout.

Reply via email to