The option I want to implement, and which my be a suitable solution for your situation, is to combine the object id with the slugified version of the object name. Then in your urls.py, only capture the object id and ignore the slug when retrieving the object (this gets you past any issues with reversibility). So you'd end up with something like:
def get_absolute_url(self): return "/characters/%s/" % self.id + '-' + (slugify(self.name)) ...in your model, resulting in a url like "/characters/123-bob-and- jane". Your urls.py would need something like: (r'^characters/(?P<id>\d+)[-\w]+/$', object_detail, ... This should capture the '123' of the slug and ignore the '-bob-and- jane'. So you only use the slug for pretty urls aka human readable and search engine friendly urls but still rely on the id value for quick and painless database lookups. My question is did you write your own 'slugify' method or is this included in core somewhere and I just need the appropriate import statement in my model files? Cheers, John-Scott On Jul 6, 4:27 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > >> You might need to adopt a different approach to URL construction that is > >> reversible (writing your own version of slugify, possibly?). > > > Thanks for the help Malcolm. Using Jeff Croft's "I'm not a programmer" > > excuse, would it be too much trouble to request a small example of a > > reversible slugify? > > Given that any general "slugify" method throws away information > (case, spaces, punctuation, etc), there's no way to fabricate > that information for reversal short of keeping the original and > working backwards. > > However, you can use the urllib.quote() and urllib.unquote() > functions instead, which may do the trick. > > You may have to modify the regexp in your urls.py to handle > standard quoted characters rather than just "slug" chars. > > -tim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---