channels 설치 명령어
pipenv install channels
(django_chat-JUgRnoSN) E:\project\django_chat>pipenv install channels
Creating a Pipfile for this project...
Installing channels...
Adding channels to Pipfile's [packages]...
Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
Success!
Updated Pipfile.lock (a7b586)!
Installing dependencies from Pipfile.lock (a7b586)...
================================ 0/0 - 00:00:00
channels 적용 전 후 비교
channels 적용 전
(django_chat-JUgRnoSN) E:\project\django_chat>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
July 03, 2021 - 14:35:02
Django version 3.2.5, using settings 'config.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
channels 적용 후
(django_chat-JUgRnoSN) E:\project\django_chat>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
July 03, 2021 - 15:23:22
Django version 3.2.5, using settings 'config.settings'
Starting ASGI/Channels version 3.0.3 development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
channels 적용 전과 후의 차이는
Starting ASGI/Channels version 3.0.0 development server at http://127.0.0.1:8000/.
이다.
이것은 channels 개발 서버가 Django 개발 서버로부터 넘겨받았음을 나타낸다.
wsgi.py VS asgi.py
wsgi.py
"""
WSGI config for config project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
application = get_wsgi_application()
asgi.py
# config/asgi.py
"""
ASGI config for ToDoList_Django project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
"""
import os
from channels.routing import ProtocolTypeRouter
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
application = ProtocolTypeRouter({
"http": get_asgi_application(),
# Just HTTP for now. (We can add other protocols later.)
})
출처
https://channels.readthedocs.io/en/stable/tutorial/part_1.html
Tutorial Part 1: Basic Setup — Channels 3.0.3 documentation
In this tutorial we will build a simple chat server. It will have two pages: The room view will use a WebSocket to communicate with the Django server and listen for any messages that are posted. We assume that you are familiar with basic concepts for build
channels.readthedocs.io
'개발 공부 > Django' 카테고리의 다른 글
django channels - Tutorial Part 3: Rewrite Chat Server as Asynchronous (0) | 2021.07.04 |
---|---|
django channels - Tutorial Part 2: Implement a Chat Server (0) | 2021.07.04 |
Serializer (0) | 2021.06.22 |
Django 기술 면접 질문들 (0) | 2021.06.13 |
오류 - models.W042 (0) | 2021.05.31 |