On 23 Jul 2009, at 16:30 , nbv4 wrote: > I'm looking into adding prettier URLs into my site with the help of > slugs. I've never done something like this before, so I'm doing a lot > of reading and am having trouble "getting" slugs. When creating URLs, > couldn't you just do do something like "example.com/45/slug-goes- > here"? Then have the view only use the 45 (the ID) to look up the blog > entry (or whatever).
Yes you could. > It seems that the way > you're supposed to do it involves a seperate slug field that gets > stored in the database. What is the point of this? I'm about to > implement this the way I described above. Is there anything I'm > missing? Well I usually set the slug field as the pk (which removes the `id` field Django automatically adds to the table). That way I get `example.com/slug-goes-here` and the view only uses the slug to look up the item, not an artificial ID (naturally one can also consider the slug to be artificial: since it's a transformation on the name/title of the item/entry, one could use the name/title as a PK, though I don't think even Django 1.1's extensions to the ORM handle that kind of cases gracefully). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---