1 2 3 4 5 6 7 8 9 10 11 12 | def urlsafestring(string):
from string import strip, rstrip, lstrip, replace
string = str(string)
badchars = [".",",","+","=","%","#","!","@","$","^","*","(",")","\\","/","\"","[","]","{","}","|","'","?"]
for b in badchars:
string = replace(string, b, "")
string = rstrip(string)
string = lstrip(string)
string = replace(string, "-", "_")
string = replace(string, " ", "_")
string = replace(string, "__", "_")
return string
|
More like this
- Unfuddle-style post-commit emails - tied to a specific Django project. by jsandell 4 years, 8 months ago
- Dynamically Import a Module (and return it) by joshua 6 years, 2 months ago
- TruncateChars by Aveal 5 years, 7 months ago
- Download images as png or pdf by gkelly 6 years, 1 month ago
- Effective content caching for mass-load site using redirect feature by nnseva 1 year, 10 months ago
Comments
this might be better:
Example:
#
Isn't this essentially the same as Django's
slugifyfilter?#