am having a problem with char inside numeric data, it’s too large to be cleaned. anyways.
I want to replace < and > from value.
just posting relevant codes.
views.py
def search_result(request):
if request.method == "POST":
ChemSearched = request.POST.get('ChemSearched')
tarname = BINDLL.objects.filter(targetnameassignedbycuratorordatasource__contains=ChemSearched).exclude(ki_nm__isnull=True)[:120]
return render(request, 'Search/search_result.html',{'ChemSearched':ChemSearched,'tarname':tarname})
Html side
<script>
data=[{% for Bindll in tarname %} {
group: '{{ Bindll.targetnameassignedbycuratorordatasource }}',
variable:'{{ Bindll.zincidofligand}}',
value: {{Bindll.ki_nm|safe}}
}, {% endfor %}];
which is used by graph d3.js.
all go well unless I have ‘<‘ or ‘>’ in value I’ll have this result
Uncaught SyntaxError: Unexpected token ‘>’
or if use escape value: {{Bindll.ki_nm|escape}}
Uncaught SyntaxError: Unexpected token ‘<’
any function to be used in Html side javascript to replace char or anything and keep only numeric like regex replace.
thanks.