django - escape % character in Python -



django - escape % character in Python -

i have next string in python, rendered in template django.

link_string = '<a href="/search/?q=%23%s"> %s </a>'

it link search url %23 '#', because i'm trying search objects #hashtag.

i intend interpolate string 2 values, %s after %23 , one:

link_href = link_string % ('hashtag_value', 'link name')

what proper way obtain next final string:

<a href="/search/?q=%23hashtag_value"> link name </a>

thank much

link_string = '<a href="/search/?q=%%23%s"> %s </a>'

python django string escaping design-patterns

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -