I am trying to scan QR code using javascript as shown below. this part is working fine:
<title>Django Online Barcode Reader</title>
<meta charset="utf-8">
{% csrf_token %}
<script src={% static "html5-qrcode.min.js"%}></script>
<style>
.result{
background-color: green;
color:#fff;
padding:20px;
}
.row{
display:flex;
}
</style>
<!--<form action="" method="POST">-->
{% csrf_token %}
<div class="row">
<div class="col">
<div style="width:500px;" id="reader"></div>
</div>
<div class="col" style="padding:30px;">
<h4>SCAN RESULT</h4>
<!--<div id="result" name="result">Result Here</div>-->
<output type="post" id="result" name="resutl" placeholder="qrCodeMessage">
</div>
</div>
<script type="text/javascript">
function onScanSuccess(qrCodeMessage) {
document.getElementById('result').innerHTML = '<span class="result">'+qrCodeMessage+'</span>';}
function onScanError(errorMessage) {
//handle scan error
}
var html5QrcodeScanner = new Html5QrcodeScanner(
"reader", { fps: 10, qrbox: 250 });
html5QrcodeScanner.render(onScanSuccess, onScanError);
</script>
But I need to pass the value of result variable to python function as following and print it but did not work. It does not print any!
def userspage(request):
if request.method == 'POST':
result = request.POST.get("result")
context = {}
print(result)
return render(request, 'users.html', context)
I need your usual help to fix this. Thanks,