I am trying to add an anchor to my url in a django template like this:
<a data-hover="Are You At Risk?" href="{% url 'home' %}#container">My link</a>
This does not work.
How can I get this to move to the anchor point when this link is clicked?
A Django template is a text document or a Python string marked-up using the Django template language. Django being a powerful Batteries included framework provides convenience to rendering data in a template.
Just use the same label {% url 'index' %} . You may use each name in urls.py to link to the url. Show activity on this post. Create a new URL in the same format and give that name instead of index.
Make sure the actual anchor is defined like this in your template:
<a name="container"></a>
And then link to it the way you did:
<a data-hover="Are You At Risk?" href="{% url 'home' %}#container">My link</a>
If this does not work add /
just before your #
-tag:
<a data-hover="Are You At Risk?" href="{% url 'home' %}/#container">My link</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With