I want my colons slugified into dashes instead of empty strings. I guess I could put something like slugify(self.name.replace(":", "-"))
into my save()
methods but that wouldn't be DRY at all (I think).
Also I could add that .replace()
operation directly into django.utils.text.slugify
def slugify(value):
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = value.replace(":", "-")
value = re.sub('[^\w\s-]', '', value).strip().lower()
return mark_safe(re.sub('[-\s]+', '-', value))
This doesn't seem like a good idea. How do I do it with regex?
- How do I do it with regex?
- How do I tie this override to a project rather than doing it inside django package?