Channels在PyPI上就有——安裝只要運(yùn)行:
pip install -U channels
運(yùn)行完后,將channels添加到你的INSTALLED_APPS設(shè)置中:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
...
'channels',
)
大功告成!設(shè)置好后,channels會(huì)將自己整合到Django中并且控制runserver命令。更多信息參見(jiàn)Getting Started with Channels.
注意
某些三方應(yīng)用會(huì)重載或者取代 runserver 命令。Channels使用單獨(dú)的 runserver 命令,可能會(huì)與這些三方應(yīng)用沖突,比如whitenoise的whitenoise.runserver_nostatic。為了避免沖突,請(qǐng)將 channels 移到 INSTALLED_APPS 設(shè)置的首行,或者移除沖突的應(yīng)用。
安裝最新開(kāi)發(fā)版
要安裝最新的開(kāi)發(fā)版本,請(qǐng)自己clone這個(gè)repo, 進(jìn)入到repo的路徑,然后在你的虛擬環(huán)境中用pip安裝:
$ git clone git@github.com:django/channels.git
$ cd channels
$ <activate your project’s virtual environment>
(environment) $ pip install -e . # the dot specifies the current repo