python - How do I write a Django template custom tag that adds a slash before a single quote? -


Am I doing this right? (Maybe not ... is there any right? Thanks)

prefix <@> register.filter ('addlashes') adds @stringfilter def (text, RGR): return text.rele ('\' ',' \\ '') {{query | Addlashes}}

Filter with the exact same name:

This also avoids double quotes, and double slash. If you want only single quotes, you have to customize it and give it a different name.

The original works here:

  def addslashes (value): "" It is useful to avoid strings in CSV, for example, to avoid javascript Less is useful, instead use `` `` AJAX`` filter. ('' ',' \\ '). ("'," \\ ") adds add_shes_safe = true addlashes = stringfilter (addslashes)  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -