I have an object that has a title.  I'd like to use the title to
pre-populate a slug field for use in URLs so I can have descriptive
URLs.

Instead of: /myobject/(?P<object_id>\d+)/
I want: /myobject/(?P<slug>[-\w]+)/

I'm concerned if the user types in a title that's already taken.  Slug
fields get a db_index=True by default.  Does that mean it must be
unique in the database or simply that it will index this column.  I'm
thinking (and hoping) the latter.

But how do you look up by a field that could result in multiple rows in
the case that the user types a title that results in a duplicate slug?

Do you set the url to be something like this?
/myobject/(?P<object_id>\d+)/(?P<slug>[-\w]+)/

Thanks,
Rob


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to