{"id":5917,"date":"2024-05-25T15:21:20","date_gmt":"2024-05-25T19:21:20","guid":{"rendered":"https:\/\/www.cloudsurph.com\/?p=5917"},"modified":"2024-05-25T15:21:37","modified_gmt":"2024-05-25T19:21:37","slug":"building-a-chat-application-django","status":"publish","type":"post","link":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/","title":{"rendered":"Building a Chat Application Django"},"content":{"rendered":"<h3>Real-Time Features with Django Channels: Building a Chat Application<\/h3>\n<p>Building a real-time chat application with Django Channels involves several steps. Django Channels extends Django to handle WebSockets, enabling real-time functionality. Here&#8217;s a step-by-step guide to create a basic chat application:<\/p>\n<h3>Step 1: Setting Up the Environment<\/h3>\n<h4>1.1 Install Required Packages<\/h4>\n<p>First, ensure you have Django and Django Channels installed:<\/p>\n<pre class=\"prettyprint\">\r\npip install django channels channels-redis\r\n<\/pre>\n<h4>1.2 Create a Django Project and App<\/h4>\n<p>Create a new Django project and app:<\/p>\n<pre class=\"prettyprint\">\r\ndjango-admin startproject chatproject\r\ncd chatproject\r\ndjango-admin startapp chat\r\n<\/pre>\n<h3>Step 2: Configure Django Channels<\/h3>\n<h4>2.1 Update <code>settings.py<\/code><\/h4>\n<p>Add <code>channels<\/code> to your <code>INSTALLED_APPS<\/code>:<\/p>\n<pre class=\"prettyprint\">\r\nINSTALLED_APPS = [\r\n...\r\n'channels',\r\n'chat',\r\n]\r\n<\/pre>\n<p>Set the ASGI application and configure the channel layers:<\/p>\n<pre class=\"prettyprint\">\r\nASGI_APPLICATION = 'chatproject.asgi.application'\r\n\r\nCHANNEL_LAYERS = {\r\n \u00a0 'default': {\r\n\u00a0 \u00a0 \u00a0 \u00a0 'BACKEND': 'channels_redis.core.RedisChannelLayer',\r\n\u00a0 \u00a0 \u00a0 \u00a0 'CONFIG': {\r\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'hosts': [('127.0.0.1', 6379)],\r\n \u00a0 \u00a0 \u00a0 },\r\n \u00a0 },\r\n}\r\n<\/pre>\n<h4>2.2 Create <code>asgi.py<\/code><\/h4>\n<p>Modify <code>asgi.py<\/code> to include Channels routing:<\/p>\n<pre class=\"prettyprint\">\r\nimport os\r\nfrom channels.routing import ProtocolTypeRouter, URLRouter\r\nfrom channels.auth import AuthMiddlewareStack\r\nfrom django.core.asgi import get_asgi_application\r\nimport chat.routing\r\n\r\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chatproject.settings')\r\n\r\napplication = ProtocolTypeRouter({\r\n\u00a0 \u00a0 \"http\": get_asgi_application(),\r\n\u00a0 \u00a0 \"websocket\": AuthMiddlewareStack(\r\n\u00a0 \u00a0 \u00a0 \u00a0 URLRouter(\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 chat.routing.websocket_urlpatterns\r\n\u00a0 \u00a0 \u00a0 \u00a0 )\r\n\u00a0 \u00a0 ),\r\n})\r\n<\/pre>\n<h3>Step 3: Define Routing<\/h3>\n<h4>3.1 Create <code>routing.py<\/code> in the <code>chat<\/code> app<\/h4>\n<pre class=\"prettyprint\">\r\nfrom django.urls import re_path\r\nfrom . import consumers\r\n\r\nwebsocket_urlpatterns = [\r\n\u00a0 \u00a0 re_path(r'ws\/chat\/(?P&lt;room_name&gt;\\w+)\/$', consumers.ChatConsumer.as_asgi()),\r\n]\r\n<\/pre>\n<h3>Step 4: Create Consumers<\/h3>\n<h4>4.1 Create <code>consumers.py<\/code> in the <code>chat<\/code> app<\/h4>\n<p>Consumers handle the WebSocket connections:<\/p>\n<pre class=\"prettyprint\">\r\nimport json\r\nfrom channels.generic.websocket import AsyncWebsocketConsumer\r\n\r\nclass ChatConsumer(AsyncWebsocketConsumer):\r\n\u00a0 \u00a0 async def connect(self):\r\n \u00a0 \u00a0 \u00a0 self.room_name = self.scope['url_route']['kwargs']['room_name']\r\n\u00a0 \u00a0 \u00a0 \u00a0 self.room_group_name = f'chat_{self.room_name}'\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 # Join room group\r\n\u00a0 \u00a0 \u00a0 \u00a0 await self.channel_layer.group_add(\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 self.room_group_name,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 self.channel_name\r\n\u00a0 \u00a0 \u00a0 \u00a0 )\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 await self.accept()\r\n\r\n\u00a0 \u00a0 async def disconnect(self, close_code):\r\n\u00a0 \u00a0 \u00a0 \u00a0 # Leave room group\r\n\u00a0 \u00a0 \u00a0 \u00a0 await self.channel_layer.group_discard(\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 self.room_group_name,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 self.channel_name\r\n\u00a0 \u00a0 \u00a0 \u00a0 )\r\n\r\n\u00a0 \u00a0 async def receive(self, text_data):\r\n\u00a0 \u00a0 \u00a0 \u00a0 text_data_json = json.loads(text_data)\r\n\u00a0 \u00a0 \u00a0 \u00a0 message = text_data_json['message']\r\n\r\n \u00a0 \u00a0 \u00a0 # Send message to room group\r\n \u00a0 \u00a0 \u00a0 await self.channel_layer.group_send(\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 self.room_group_name,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'type': 'chat_message',\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'message': message\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\r\n\u00a0 \u00a0 \u00a0 \u00a0 )\r\n\r\n \u00a0 async def chat_message(self, event):\r\n\u00a0 \u00a0 \u00a0 \u00a0 message = event['message']\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 # Send message to WebSocket\r\n\u00a0 \u00a0 \u00a0 \u00a0 await self.send(text_data=json.dumps({\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'message': message\r\n\u00a0 \u00a0 \u00a0 \u00a0 }))\r\n<\/pre>\n<h3>Step 5: Create Templates and Views<\/h3>\n<h4>5.1 Create a Simple Chat Room Template<\/h4>\n<p>Create <code>templates\/chat\/room.html<\/code>:<\/p>\n<pre class=\"prettyprint\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\u00a0 \u00a0 &lt;title&gt;Chat Room&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\u00a0 \u00a0 &lt;h1&gt;Room: {{ room_name }}&lt;\/h1&gt;\r\n\u00a0 \u00a0 &lt;div id=\"chat-log\"&gt;&lt;\/div&gt;\r\n\u00a0 \u00a0 &lt;input id=\"chat-message-input\" type=\"text\" size=\"100\"&gt;\r\n\u00a0 \u00a0 &lt;input id=\"chat-message-submit\" type=\"button\" value=\"Send\"&gt;\r\n\r\n\u00a0 \u00a0 &lt;script&gt;\r\n\u00a0 \u00a0 \u00a0 \u00a0 const roomName = \"{{ room_name }}\";\r\n\u00a0 \u00a0 \u00a0 \u00a0 const chatSocket = new WebSocket(\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'ws:\/\/' + window.location.host + '\/ws\/chat\/' + roomName + '\/'\r\n\u00a0 \u00a0 \u00a0 \u00a0 );\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 chatSocket.onmessage = function(e) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 const data = JSON.parse(e.data);\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 document.querySelector('#chat-log').innerHTML += (data.message + '&lt;br&gt;');\r\n\u00a0 \u00a0 \u00a0 \u00a0 };\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 chatSocket.onclose = function(e) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 console.error('Chat socket closed unexpectedly');\r\n\u00a0 \u00a0 \u00a0 \u00a0 };\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 document.querySelector('#chat-message-input').focus();\r\n\u00a0 \u00a0 \u00a0 \u00a0 document.querySelector('#chat-message-input').onkeyup = function(e) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if (e.keyCode === 13) {\u00a0 \/\/ Enter key\r\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 document.querySelector('#chat-message-submit').click();\r\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\r\n\u00a0 \u00a0 \u00a0 \u00a0 };\r\n\r\n \u00a0 \u00a0 \u00a0 document.querySelector('#chat-message-submit').onclick = function(e) {\r\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 const messageInputDom = document.querySelector('#chat-message-input');\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 const message = messageInputDom.value;\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 chatSocket.send(JSON.stringify({\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'message': message\r\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }));\r\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 messageInputDom.value = '';\r\n\u00a0 \u00a0 \u00a0 \u00a0 };\r\n \u00a0 &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h4>5.2 Create Views<\/h4>\n<p>Update <code>views.py<\/code> in the <code>chat<\/code> app:<\/p>\n<pre class=\"prettyprint\">\r\nfrom django.shortcuts import render\r\n\r\ndef room(request, room_name):\r\n\u00a0 \u00a0 return render(request, 'chat\/room.html', {\r\n\u00a0 \u00a0 \u00a0 \u00a0 'room_name': room_name\r\n\u00a0 \u00a0 })\r\n<\/pre>\n<h4>5.3 Define URL Patterns<\/h4>\n<p>Update <code>urls.py<\/code> in the <code>chat<\/code> app:<\/p>\n<pre class=\"prettyprint\">\r\nfrom django.urls import path\r\nfrom . import views\r\n\r\nurlpatterns = [\r\n\u00a0 \u00a0 path('&lt;str:room_name&gt;\/', views.room, name='room'),\r\n]<\/pre>\n<p>Update the project\u2019s <code>urls.py<\/code> to include the <code>chat<\/code> app\u2019s URLs:<\/p>\n<pre class=\"prettyprint\">\r\nfrom django.contrib import admin\r\nfrom django.urls import path, include\r\n\r\nurlpatterns = [\r\n\u00a0 \u00a0 path('admin\/', admin.site.urls),\r\n\u00a0 \u00a0 path('chat\/', include('chat.urls')),\r\n]\r\n<\/pre>\n<h3>Step 6: Running the Application<\/h3>\n<p>Make sure you have Redis running, as it\u2019s the default channel layer backend.<\/p>\n<p><strong>Run migrations:<\/strong><\/p>\n<pre class=\"prettyprint\">\r\npython manage.py migrate\r\n<\/pre>\n<p><strong>Run the development server:<\/strong><\/p>\n<pre class=\"prettyprint\">\r\npython manage.py runserver\r\n<\/pre>\n<p>Visit <code>http:\/\/127.0.0.1:8000\/chat\/room_name\/<\/code> (replace <code>room_name<\/code> with any room name) to test your chat application. Open multiple browser tabs to see real-time messaging in action.<\/p>\n<p>This setup provides the basic framework for a real-time chat application using Django Channels. For production, consider additional steps like deploying with a proper ASGI server (e.g., Daphne, Uvicorn) and configuring security settings.<\/p>\n<h4>Recent Posts<\/h4>\n<ul>\n<li><a href=\"https:\/\/www.cloudsurph.com\/django-views-and-templates-rendering-dynamic-web-pages\/\" aria-current=\"page\">Django Views and Templates: Rendering Dynamic Web Pages<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/understanding-django-models-building-the-data-structure\/\">Understanding Django Models: Building the Data Structure<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/creating-a-crud-application-with-django\/\">Creating a CRUD Application with Django<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/django-fundamentals-setting-up-your-first-project\/\">Django Fundamentals: Setting Up Your First Project<\/a><\/li>\n<li><a href=\"https:\/\/www.cloudsurph.com\/migrating-from-older-versions-of-laravel-best-practices-and-considerations\/\">Migrating from Older Versions of Laravel: Best Practices and Considerations<\/a><\/li>\n<\/ul>\n<h5><em><strong>If you want then buy a good, reliable, secure web\u00a0<a href=\"https:\/\/www.cloudsurph.com\/windows-vps-hosting\/\">hosting<\/a>\u00a0service \u00a0from here:\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">click here<\/a><\/strong><\/em><\/h5>\n<p>In Conclusion,\u00a0 If you enjoyed reading this article and have more questions please reach out to our\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/submitticket.php?step=2&amp;deptid=1\">support team<\/a>\u00a0via live chat or\u00a0<a href=\"mailto:support@cloudsurph.com\">email<\/a>\u00a0and we would be glad to help you.\u00a0In Other Words, we provide server\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">hosting<\/a>\u00a0for all types of need and we can even get your\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">server<\/a>\u00a0up and running with the service of your choice.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Real-Time Features with Django Channels: Building a Chat Application Building a real-time chat application with Django Channels involves several steps. Django Channels extends Django to handle WebSockets, enabling real-time functionality. Here&#8217;s a step-by-step guide to create a basic chat application: Step 1: Setting Up the Environment 1.1 Install Required Packages First, ensure you have Django [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":5876,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[157,25,163,158,159,44,1],"tags":[54,47,105,103,48,113],"class_list":["post-5917","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos-7","category-web-hosting-virtualization","category-django","category-linux-basics","category-linux-server","category-kvm-xen","category-virtual-private-servers","tag-best-vps-hosting-server-maryland","tag-cheap-cloud-servers","tag-cheap-storage-server-hosting","tag-cheapest-vps","tag-dedicated-server-hosting-in-washington-d-c","tag-speed-test-vps"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Building a Chat Application Django - Cloudsurph Web Hosting Washington D.C.<\/title>\n<meta name=\"description\" content=\"Building a Chat Application Django with Real-Time Features with Django Channels: Building a Chat Application\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building a Chat Application Django - Cloudsurph Web Hosting Washington D.C.\" \/>\n<meta property=\"og:description\" content=\"Building a Chat Application Django with Real-Time Features with Django Channels: Building a Chat Application\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudsurph Web Hosting Washington D.C.\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/CloudSurph\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-05-25T19:21:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-25T19:21:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2024\/03\/Django-Fundamentals-Setting-Up-Your-First-Project.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Rony\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cloudsurph\" \/>\n<meta name=\"twitter:site\" content=\"@Cloud_Surph\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rony\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/\"},\"author\":{\"name\":\"Rony\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/person\\\/ac9b4dd136d96e50d5f29c560191e7ed\"},\"headline\":\"Building a Chat Application Django\",\"datePublished\":\"2024-05-25T19:21:20+00:00\",\"dateModified\":\"2024-05-25T19:21:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/\"},\"wordCount\":348,\"publisher\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Django-Fundamentals-Setting-Up-Your-First-Project.png\",\"keywords\":[\"Best VPS hosting server Maryland\",\"Cheap Cloud Servers\",\"Cheap Storage Server Hosting\",\"Cheapest VPS\",\"Dedicated Server Hosting in Washington D.C\",\"Speed test VPS\"],\"articleSection\":[\"CentOS 7\",\"Cloud Hosting\",\"Django\",\"Linux Basics\",\"Linux Server\",\"Virtualization\",\"VPS Servers\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/\",\"name\":\"Building a Chat Application Django - Cloudsurph Web Hosting Washington D.C.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Django-Fundamentals-Setting-Up-Your-First-Project.png\",\"datePublished\":\"2024-05-25T19:21:20+00:00\",\"dateModified\":\"2024-05-25T19:21:37+00:00\",\"description\":\"Building a Chat Application Django with Real-Time Features with Django Channels: Building a Chat Application\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Django-Fundamentals-Setting-Up-Your-First-Project.png\",\"contentUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Django-Fundamentals-Setting-Up-Your-First-Project.png\",\"width\":1280,\"height\":720,\"caption\":\"Implementing Internationalization and Localization in Django\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/building-a-chat-application-django\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.cloudsurph.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building a Chat Application Django\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#website\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/\",\"name\":\"Cloudsurph Web Hosting Washington D.C.\",\"description\":\"Dedicated Server Hosting\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.cloudsurph.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\",\"name\":\"CloudSurph Technology Solutions\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/cloudsurph-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/cloudsurph-logo.png\",\"width\":2348,\"height\":1692,\"caption\":\"CloudSurph Technology Solutions\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/CloudSurph\\\/\",\"https:\\\/\\\/x.com\\\/Cloud_Surph\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/person\\\/ac9b4dd136d96e50d5f29c560191e7ed\",\"name\":\"Rony\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"caption\":\"Rony\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/cloudsurph\"],\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/author\\\/ron\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Building a Chat Application Django - Cloudsurph Web Hosting Washington D.C.","description":"Building a Chat Application Django with Real-Time Features with Django Channels: Building a Chat Application","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/","og_locale":"en_US","og_type":"article","og_title":"Building a Chat Application Django - Cloudsurph Web Hosting Washington D.C.","og_description":"Building a Chat Application Django with Real-Time Features with Django Channels: Building a Chat Application","og_url":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/","og_site_name":"Cloudsurph Web Hosting Washington D.C.","article_publisher":"https:\/\/www.facebook.com\/CloudSurph\/","article_published_time":"2024-05-25T19:21:20+00:00","article_modified_time":"2024-05-25T19:21:37+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2024\/03\/Django-Fundamentals-Setting-Up-Your-First-Project.png","type":"image\/png"}],"author":"Rony","twitter_card":"summary_large_image","twitter_creator":"@cloudsurph","twitter_site":"@Cloud_Surph","twitter_misc":{"Written by":"Rony","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/#article","isPartOf":{"@id":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/"},"author":{"name":"Rony","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/person\/ac9b4dd136d96e50d5f29c560191e7ed"},"headline":"Building a Chat Application Django","datePublished":"2024-05-25T19:21:20+00:00","dateModified":"2024-05-25T19:21:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/"},"wordCount":348,"publisher":{"@id":"https:\/\/www.cloudsurph.com\/#organization"},"image":{"@id":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2024\/03\/Django-Fundamentals-Setting-Up-Your-First-Project.png","keywords":["Best VPS hosting server Maryland","Cheap Cloud Servers","Cheap Storage Server Hosting","Cheapest VPS","Dedicated Server Hosting in Washington D.C","Speed test VPS"],"articleSection":["CentOS 7","Cloud Hosting","Django","Linux Basics","Linux Server","Virtualization","VPS Servers"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/","url":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/","name":"Building a Chat Application Django - Cloudsurph Web Hosting Washington D.C.","isPartOf":{"@id":"https:\/\/www.cloudsurph.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/#primaryimage"},"image":{"@id":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2024\/03\/Django-Fundamentals-Setting-Up-Your-First-Project.png","datePublished":"2024-05-25T19:21:20+00:00","dateModified":"2024-05-25T19:21:37+00:00","description":"Building a Chat Application Django with Real-Time Features with Django Channels: Building a Chat Application","breadcrumb":{"@id":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/#primaryimage","url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2024\/03\/Django-Fundamentals-Setting-Up-Your-First-Project.png","contentUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2024\/03\/Django-Fundamentals-Setting-Up-Your-First-Project.png","width":1280,"height":720,"caption":"Implementing Internationalization and Localization in Django"},{"@type":"BreadcrumbList","@id":"https:\/\/www.cloudsurph.com\/building-a-chat-application-django\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cloudsurph.com\/"},{"@type":"ListItem","position":2,"name":"Building a Chat Application Django"}]},{"@type":"WebSite","@id":"https:\/\/www.cloudsurph.com\/#website","url":"https:\/\/www.cloudsurph.com\/","name":"Cloudsurph Web Hosting Washington D.C.","description":"Dedicated Server Hosting","publisher":{"@id":"https:\/\/www.cloudsurph.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.cloudsurph.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.cloudsurph.com\/#organization","name":"CloudSurph Technology Solutions","url":"https:\/\/www.cloudsurph.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2016\/04\/cloudsurph-logo.png","contentUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2016\/04\/cloudsurph-logo.png","width":2348,"height":1692,"caption":"CloudSurph Technology Solutions"},"image":{"@id":"https:\/\/www.cloudsurph.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/CloudSurph\/","https:\/\/x.com\/Cloud_Surph"]},{"@type":"Person","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/person\/ac9b4dd136d96e50d5f29c560191e7ed","name":"Rony","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","caption":"Rony"},"sameAs":["https:\/\/x.com\/cloudsurph"],"url":"https:\/\/www.cloudsurph.com\/author\/ron\/"}]}},"_links":{"self":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/comments?post=5917"}],"version-history":[{"count":2,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5917\/revisions"}],"predecessor-version":[{"id":5919,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5917\/revisions\/5919"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/media\/5876"}],"wp:attachment":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/media?parent=5917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/categories?post=5917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/tags?post=5917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}