Skip to content
Advertisement

Get html link id in django views.py

This is what my template index.html looks like

JavaScript

And here is my urls.py file

JavaScript

Finally, this is my link view inside of the views.py file

JavaScript

Where page() is a function that takes one argument. I want the id of the <a></a> tag of index.html to be that argument. But I have no idea how to access get that id inside of views.py when the <a></a> tag is clicked

Advertisement

Answer

Replace your statement with this line inside index.html.

JavaScript

Your urls.py should contain

JavaScript

Now, you should get the id in the id variable of the views.py when the tag is clicked.

Advertisement