教程:http://channels.readthedocs.io/en/latest/tutorial
所需工具:
1、安装python
2、安装django
3、安装channel
4、安装Docker
5、有vs2015、win32
6、下载chrome并安装ChromeDriver
7、安装Selenium、chromedriver
遇到的问题及解决方案:
1、docker注册id的时候,sign up灰色无法点击,挂个pvn就解决了
2、在安装django的时候,一直显示路径编码错误,后来发现是用户名为中文“起名太好听”(为什么当时这么皮)之后重装系统后完美解决
3、在实现WebSocket进行消息广播的时候提示
Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them.
AttributeError: 'WebSocketProtocol' object has no attribute 'application_queue'
控制台提示未连接服务器
【解决方法】python manage.py migrate
4、在安装chromedriver时,务必要把文件放在chrome的安装目录下,安装成功与否的测试代码如下,注意路径要改成自己的chrome路径
import time from selenium import webdriver driver = webdriver.Chrome('C:\Program Files (x86)\Google\Chrome\Application\chromedriver') # Optional argument, if not specified will search path. driver.get('http://www.google.com/xhtml'); time.sleep(5) # Let the user actually see something! search_box = driver.find_element_by_name('q') search_box.send_keys('ChromeDriver') search_box.submit() time.sleep(5) # Let the user actually see something! driver.quit()