I want to define a link for a character in the view. I used the following code, but it has an error. Error: Encountered unknown tag 'url'
code:
html="""
<p>
<a href="{% url index2 %}">more information</a>
</p>
"""
I use the Folium library and want to put a link in the popup. So I can not use the normal mode and I have used the above method.
CodePudding user response:
you need to make entry in URL.py with url index2/ and view.{function in view you want to call to execute on clicl}
CodePudding user response:
You have template tags in your HTML, so you have to pass it through the Django template processor:
from django.template import Template, Context
html = Template(
"""
<p>
<a href="{% url index2 %}">more information</a>
</p>
""").render(Context({}))
Note that extra spaces included in your quoted string will appear in the html output.
Also note that I am passing an empty dictionary to construct the Context
, but if you were to put some entries into that dictionary, they would be available as template variables in the template.