Reputation: 9
i'm working with a flask to make a dashborard, in my project i have a script inside the flask app that generates the html code. and my question is how to use url_for to create the dynamic routing is this case, here is my code:
rec+='<td><a href="url_for(case,id='+row['ID']+'" id="'+str(row['ID'])+'" >More</a></td>'
Any ideas how to make it work and thank you in advance.
Upvotes: 0
Views: 378
Reputation: 6475
You should use {{ }}
enclose the url_for
statement.
rec += '<td><a href="{{ url_for(case, id=' + str(row['ID']) + ') }}">More</a></td>'
or use format string(more readable):
rec += '<td><a href="{{ url_for(case, id={}) }}">More</a></td>'.format(row['ID'])
Upvotes: 2