@register.filter(is_safe=True)
@stringfilter
def addslashes(value):
 return value.replace('\\', '\\\\').replace('"', '\\"').replace("'", "\\'")

@ register . filter ( is_safe = True ) @ stringfilter def addslashes ( value ) : return value . replace ( '\\' , '\\\\' ) . replace ( '"' , '\\"' ) . replace ( "'" , "\\'" )
adds slashes - useful for passing strings to javascript .