1 2 3 4 5 6 7 8 9 10 11 12 13 | from django.template import Library
from django.template.defaultfilters import slugify, stringfilter
register = Library()
@register.filter
@stringfilter
def slug_and_slash_to_dash(value):
"""
Converts any slashes in the given value into spaces, then slugify's the result.
Leading and Trailing slashes (e.g. /some/url/) are ignored.
"""
return slugify(' '.join(value.split('/')))
|
More like this
- Smart append slash middleware by akaihola 3 years, 12 months ago
- Automatically slugify slug fields in your models by Aliquip 4 years, 11 months ago
- Using the built-in slugify filter outside a template by jcroft 4 years, 11 months ago
- Ensure submitted slugs do not conflict with existing resolvable URLs by ElfSternberg 2 years, 7 months ago
- Resolve URLs to view name and args/kwargs by fahhem 1 year, 2 months ago
Comments