[Answer]-Not able to recognise url variable in html page in django. Html page is getting generated dynamically

1👍

It is not template, This is python string. So you need to use string fromat,

Try this way,

table + = "<table> <tr> <td> <a href= \" /run/{0} \" > "+ linkname + "</a></td></tr></table>".format(id)

Another way:

from django.template import Context, Template

def run(request, id):
   table=""
   table + = "<table> <tr> <td> <a href= \" /run/{{ id }} \" > "+ linkname + "</a></td></tr>   </table>"
   t = Template(table)
   c = Context({"id": id})
   return HttpResponse(t.render(c))

Note: I didn’t find linkname variable. So django throws an error.
Doc is here

👤dhana

Leave a comment