0

I am a beginner in Django and wrote a script code but i am not able to pass the variable to django views.py

var selectedDataSet = new String('test');
function getDataSet() {
  var dataSetList = document.querySelector('#list');
  selectedDataSet = dataSetList.options[dataSetList.selectedIndex].value;
  console.log(selectedDataSet)
  return selectedDataSet;
}

this is working perfectly, but i dont know how to pass selectedDataSet to Django views.py.

alexander.polomodov
  • 5,396
  • 14
  • 39
  • 46
  • 2
    you can pass data to your server only via form submission or via AJAX – Hisagr Sep 09 '17 at 14:30
  • so should i call selectedDataSet on a form input? Will that work? – Srijan Anand Sep 10 '17 at 14:11
  • No. You need to create a jQuery function that will send JSON data to your server upon form submission. In your django view, you need to capture this data if you want to process it. – Hisagr Sep 10 '17 at 14:51

0 Answers0