On Wed, 2008-11-19 at 12:44 -0800, Nick wrote:
> Hi,
>
> I have the following strings which is run through the slugify filter
> on my site:
>
> "Business/Executives"
>
> and it becomes "businessexecutives". I'd like this to instead become
> "business-executives" (as they are actually two seperate words).
>
> I've tracked down the slugify filter to django/template/
> defaultfilters.py, but can't get my head round the regular expressions
> required to replace "/" with "-".
Anything wrong with my_string.replace('/', '-')?
> Alternatively, instead of changing the core Django install, can I
> "extend" slugify in my own app to have this behaviour?
You can write your own filter. That's the idea for this sort of
situation. Django's slugify filter works in a particular way for a
particular set of input. It's intentionally not massively customisable,
because that's just a slippery slope with no bottom in sight. Writing
your own filter is easy enough that it's the preferred solution to
adding lots of knobs and levers to some of the existing simple filters.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---