How to Build Simple Realtime Chat Application using Django 4 Part 1: Creating Django Project

In This Post, I will discuss how to build a simple real chat application using Django and ASGI Channel, here is the case

The Case

If you’re looking at adding real-time capabilities to a Django project with WebSocket, you have two main options.

Using Django Channels, a project adding WebSocket to Django, among other features. This approach is fully supported by Django. However, it requires switching to a new deployment architecture.

Deploy a separate WebSocket server next to your Django project. This technique is well suited when you need to add a small set of real-time features — maybe a notification service — to an HTTP application.

so we can build a real-time app using ASGI service and WebSocket then integrate to Django, to integrate with Django, we need to install some package called Channel

Creating A Django Project

to create a Django project we need to set up virtualenv

pip install virtualenv

to create using this command

virtualenv venv

Activate on Windows

venv\Scripts\activate

Activate on Linux or Mac

source venv/bin/activate

Installing Required Package using pip

The next step is to install a required package using pip

pip install django channels

then create a project with Django admin

django-admin startproject core

and rename the core directory to backend

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store