Django

Django Channels

WebSockets, ASGI, consumers, routing, channel layers, authentication, real-time features

24 питань зі співбесід·
Senior
1

What is Django Channels?

Відповідь

Django Channels is an extension that adds support for asynchronous protocols to Django, enabling WebSockets, HTTP2, and other non-HTTP protocols. It extends Django's synchronous request-response model by using ASGI (Asynchronous Server Gateway Interface) instead of WSGI, enabling real-time features like chat or push notifications.

2

What is the main difference between WSGI and ASGI?

Відповідь

WSGI (Web Server Gateway Interface) is synchronous and handles only one request at a time per worker, while ASGI (Asynchronous Server Gateway Interface) supports asynchronous operations and persistent connections like WebSockets. ASGI can handle multiple simultaneous connections without blocking, which is essential for real-time applications.

3

What is a Consumer in Django Channels?

Відповідь

A Consumer is the Django Channels equivalent of a Django view for asynchronous connections. It handles the complete lifecycle of a WebSocket connection: connection, message reception, response sending, and disconnection. Consumers can be synchronous (WebsocketConsumer) or asynchronous (AsyncWebsocketConsumer) and allow structuring business logic for each connection type.

4

Which Consumer method is called when a WebSocket connection is established?

5

What is the scope in Django Channels?

+21 питань зі співбесід

Опануй Django для наступної співбесіди

Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.

Почни безкоштовно