1 2 3 4 5 6 7 8 | if city:
from django.template import defaultfilters
city_slug = defaultfilters.slugify(city)
state_slug = defaultfilters.slugify(state_abbr)
if state_slug:
location_slug = city_slug + '-' + state_slug
else:
location_slug = city_slug
|
More like this
- Built-in Slugify with filtering. by jcrawford 2 years, 10 months ago
- slugify js -> python by santuri 4 years, 11 months ago
- Automatically slugify slug fields in your models by Aliquip 4 years, 11 months ago
- Login + logout script from a nub by alandelevie 3 years, 1 month ago
- Simple login script from a nub by alandelevie 3 years, 1 month ago
Comments
Yeah, I do this all the time too when importing stuff from APIs
#
People just need to realize that filters are just functions. I usually use the striptags filter when sending emails.
#