如何使用渠道websocket在Django中找到websock

如何使用渠道websocket在Django中找到websock

本文介绍了如何使用渠道websocket在Django中找到websocketbridge.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在尝试使用Django项目中的渠道来实现websocket。我正在为webscoketbridge.js获取404以下是html模板。 {%load staticfiles%} {%block title%} 投放量 {%endblock%}I am trying to implement websockets using channels in Django project. I am getting 404 for webscoketbridge.js Below is html template. {% load staticfiles %} {% block title %}Delivery{% endblock %}<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"><link href='https://fonts.googleapis.com/css?family=Satisfy' rel='stylesheet' type='text/css'><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script><script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script><script src="{% static 'channels/js/websocketbridge.js' %}" type="text/javascript"></script>此外,我尝试查看virtualenv / lib / python3.5 / site-packages / channels路径,没有js文件夹或任何名为websocketbridge.js的文件Also, I tried to have a look in the virtualenv/lib/python3.5/site-packages/channels path, there is no js folder or any file named websocketbridge.js有人解决了这个问题吗?Has anyone solved this issue?推荐答案正如@tobyspark所说的,django-channels 2中的javascript包装器已被完全删除。您可以在此处。As the way @tobyspark said, javascript wrapper has been completely removed in the django-channels 2. You can read more on how the js websocket wrapper was working in channels 1 here.清除眉毛中错误的最简单方法ser在错误所示的路径 static / channels / js /中创建一个名为websocketbridge.js的文件,或者您可以在HTML src属性中指定与静态文件的位置匹配的任何其他路径,然后从中添加代码此处。the simplest workaround to clear that error in your browser create a file called websocketbridge.js in the path shown in the error, "static/channels/js/", or you can specify any other path in your HTML src attribute matching the location of the static files and then add the code from here.但是您必须找到更好的实现。您可以使用ReconnectingWebSocket。在Channels 2发布文档中,声明可能还有其他第三方软件包用于绑定,但是我不知道其他任何软件包。But you have to find a better implementation. You can use ReconnectingWebSocket. In the channels 2 release documentation, it is stated there might be other third-party packages for the binding but I don't know any other. 这篇关于如何使用渠道websocket在Django中找到websocketbridge.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-07 03:55