My understanding of the slug field is that prettier URLs are the main  
point.

"Slug" is a newspaper-industry term, and since Django has its roots  
there, it's now a Django term.

Django does' in fact, contain a slugify function:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#slugify
You can import and use this in a view, not just in a template: from  
django.template.defaultfilters import slugify

Note that it does not enforce uniqueness; you'd have to do that  
yourself. We just append a number to the slug.
So, for example, if you already had john_smith as a slug, you'd end up  
with john_smith2.

We use unique slugs, and store them in the database. The main reason  
(I think) for storing it in the
database is the fact that you can easily retrieve a model instance  
using (slug = value) in the objects.get().

Having the ID and the slug both passed in the URL is redundant. We use  
one or the other. Your use case may
dictate a different approach, but it doesn't make sense to me to have  
two values in the URL, both of which should
be referring to the exact same record.

Shawn

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to