while doing great stuff with django I have found some clumsy behaviour of django in handling .js file. Is there a way to effectively integrate all the stuff of <script> </script> in a separate file and effectively used it with rest of the html code.
$("#likes-form").submit(function (e)
{ e.preventDefault();
var serializedData = $(this).serializeArray();
$.ajax({
type: 'POST',
url: '{% url 'blog_likes' object.slug %}',
data: serializedData,
success: function (response) {
var like_count = JSON.parse(response["like"]);
like_flag = JSON.parse(response["flag"]);
console.log(like_flag);
if(like_flag == 0){
$(".like-inner-flex-1").toggleClass('like-animate');
}else
$(".like-inner-flex-1").toggleClass('like-animate');
if(like_flag){
$('.like-btn').css({"background-color": "#d629801a" , "outline": "none"});
$('.like-inner-flex-1').css({"background-position": "right", "filter": "grayscale(0%)"});
} else {
$('.like-btn').css({"background-color": "transparent", "outline": "none"});
$('.like-inner-flex-1').css({"background-position": "right", "filter": "grayscale(100%)"});
}
$("#likes").text(`${like_count}`);
}})
})
..........................................................
if I use above script inside the same html file then it works, but in above case its not working ?? If there is any work around to do this thing , then please suggest me .
Thank you.......