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
- Testrunner with testmodels by nfg 2 years, 3 months ago
- "Zoom in" on rendered HTML that the test client returns by peterbe 3 years, 1 month ago
- EncryptField by volksman 3 years, 8 months ago
- Django and Twill by spookylukey 4 years, 1 month ago
- Word-boundary-aware string truncation template filter by josho 3 years ago
Comments
this might be better:
Example:
#
Isn't this essentially the same as Django's
slugifyfilter?#