[Answer]-Giving a id to anchor tag doesnt execute the view in django

1đź‘Ť

As Catherine mentions in the comments, your URL pattern does not match underscores, so “pf_daywise” is not a valid value for param. Maybe you meant this:

url(r'^graphs/(?P<param>\w*)/$','display_graph',name="graph1"),

0đź‘Ť

Try this:

<li><a id="b" href="{% url graph1 'pf_daywise' %}">POWERFACTOR</a>
    <ul>
        <li><a id="c" href="{% url graph1 'pf_daywise' %}">DAYWISE</a></li>
        <li><a id="d" href="{% url graph1 'pf_monthwise' %}">MONTHWISE</a></li>
    </ul>
</li>

Shot in the dark (I’d have to test), but I’m assuming “doesn’t execute” means that, when you look at the source, you don’t see the href attribute, or it’s blank, something equally weird.

My bet is that double-quotes inside other double-quotes is throwing Django’s tag parser off.

Which, if true, would be a bug in Django’s parser. But that’s entirely possible.

Just adding an id wouldn’t cause a problem otherwise.

👤Jack Shedd

Leave a comment