How to execute a python(selenium) script on clicking run button in the template view. Django

38 views
Skip to first unread message

Dimple Mathew

unread,
Jun 11, 2018, 7:37:09 AM6/11/18
to Django users
Once i select options in the drop-down, the scripts should be executed.
Index.html
 <div class="col-xs-5 selectContainer">
<select name="colors" class="form-control" multiple title="Choose Script">
<option value="black" onclick="goPython()">US BANK</option>
<option value="blue">BOKF</option>
<option value="green">COMMERCE BANK</option>
<option value="orange">MICHIAS</option>
<option value="red">TD BANK</option>
<option value="yellow">WELSFARGO</option>
<option value="white">BOA</option>
</select>
</div>
</div>


<script>
function goPython(){
$.ajax({
url: "C:\mydjango\website\automation\script\USBANK.py",
}).done(function() {
alert('finished python script');;
});
}

Views.py

def lockbox(request):
return render(request,'automation/lockbox.html')

Julio Biason

unread,
Jun 11, 2018, 7:55:30 AM6/11/18
to django...@googlegroups.com
Hi Dimple,

Your `url` is invalid. Views are exposed to the world via urls; in that, you define which URL will call which view.

If you're running Django on your machine, your URL should probably start with 'http://localhost:8000/the/url/for/your/view' -- although the `http` can be omitted, in which case the browser will use the current schema and `://localhost` can also be omitted, in which case the browser will request from the current server.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/07cc9e80-d30f-4578-82b5-abe38cff45ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Julio Biason, Sofware Engineer
AZION  |  Deliver. Accelerate. Protect.
Office: +55 51 3083 8101  |  Mobile: +55 51 99907 0554
Reply all
Reply to author
Forward
0 new messages