1👍
✅
As DrummerMann suggested it works out like this :
var sensorID = "href='{% url 'agriculture:tree_sensor' 12345 %}'";
var url_mask = sensorID.replace("12345", fields["sensor"]);
and the button to the link
"<br><a class='popup_button small_text' "+url_mask+" ><span>Sensor Page</span></a>"
Source:stackexchange.com