This tutorial is by far THE BEST Django Channels tutorial I have encountered. This provides the greatest step by step direction and clarity. Thank you!
Thanks Marc, hopefully this is just the beginning. Just need to get this channel making a little more and I will just make tutorials 24/7. There is so much more quality I can add to these tutorials - great to hear you think its the best!
Ok, I have looking for a source to learn about Django Websocket for the whole week and this video truly saved my ass. Any other videos altho may has more views but just kinda rush into the tutorial without explaining anything. This video is super informative and great explaination. Your channel is a gem. Thank you so much. Keep up the great work.
Yay! Channels takes django to next level. Thank you so much for this. Could you please show us how to deploy this as well.. Because I've not seen any good content on deploying channels to a production grade server. If you're making any series on this that would be a great content. Loving all your Django content. Keep up the good work. And again, thank you so much 🙏🏼
@@veryacademy if we're having a series on django channels another idea for this series would be, processing a huge file in background using Celery and giving real time updates in a progress bar or something. Since channel has an option to subscribe to a particular group and send updates using channel layers.
sir i love you so much you just thought me the thing ive been strugling to learn, your teaching method is abslote gold may god bless you please do more tutorial we need you
@@veryacademy We have a subject called Digital Design and Development, where we are creating websites. Though I have never used Django before, I have programmed for a long time. Yeah Denmark has really nice subjects, but I cannot get the part of printing hello world on the website to work. Must be a mistake somewhere. I must take a look when I return to two screens instead of one.
Hey! This is amazing! Thank you so much! Could you please advise in what order should a beginner watch all your playlists to gain complete knowledge and become proficient in Django? Just a piece of advice you can make a short video of this or mention it in any of your upcoming videos. Lastly, thanks again for creating these videos and making them available to global users for free.
Don't forget about ChatRoomConsumer.as_asgi() in websocket_urlpatterns if you have problem like: TypeError: __call__() missing 1 required positional argument: 'send' GL!
Learned a lot. Feedback: Wish there was a bit more clearer explanation about how the routing is taking place, how the consumers is being talked to and is talking with. Code wise it was great, but I got lost plenty and had to look up the docs for an "overview" of the concepts. First time building a Django app and I could see prerequisite Django knowledge would be beneficial for this project.
@@veryacademy I'm having an issue. around the 1:11:00 mark, we we add the chatroom view's html, and javascript for opening up a websocket. I'm getting a handshake failure and 500 error. THe docs says that should happen due to not having a consumer, but in this tutorial we had already built the consumer. So i'm not sure why the error is happening. Pls help.
@@veryacademy 2 hours later, figured it out. To anyone having this same error: I forgot to append ".as_asgi()" to "consumers.ChatRoomConsumer", so it should have been "consumers.chatRoomConsumer.as_asgi()" In your code given above, as_asgi() was missing from your code in this context. So not sure how it worked, or if you added behind the scenes, please confirm with me.
WebSocket URL: Verify that you have the correct WebSocket URL. It should start with either "ws://" or "wss://" (for secure connections). Ensure that the URL includes the correct hostname, port number, and any additional path or query parameters required.
A very good tutorial. Thank you very much. Is there another video to save the data in the database? Your last videos unfortunately continue with other topics. Furthermore it would be interesting to know how to restrict the chatroom for example for 2 users (private chat).
Hi Osmanio - really sorry I stopped this run of tutorials, at least for now - the community members were asking for more DRF that is why I concentrated all my efforts on that. I do want to come back to this and do exactly that and expand on this more to make it a little more feature rich.
so i have a question, When we are using websocket and Channels we don't store data in the database using Models? and is it that we have to use consumer, routing and the template always?
please add requirements.txt that has the package versions, That's a lot of debugging if we don't have similar packages which was used in this project will provide a lot of help
Hi, great tutorial! Question: Why do i have to / what's the benefit of including my own app ("chat" in this case) to installed apps ? I thought the settings would list all apps that are installed into my own app ? I haven't listed my own app so far and haven't noticed any difficulties so im wondering what it does
Hi Surinam, if you are referring to INSTALLED_APPS in settings. By adding your app to the list allows your app and Django to interact with each other in certain situations. For example working and interacting with databases. Here is the manual reference docs.djangoproject.com/en/3.0/ref/applications/ Any other questions please just ask.
hi sir ,you saved my time best video about channels, thanks lot, i have some doubts 1.this chat application we can put our existing project ? 2.any difference in while deployment time? 3. i am previously using redis on windos 10 but not working then i used channels.layers.InMemoryChannelLayer 4 in production we use inmemorychannel layer
Hello, 1 - yes indeed you can put it into an existing project - sorry I cant really be anymore specific here. 2 - Yes I think I did make a tutorial where we deployed it - this is just a really basic example - I will revisit this series once we have established more DRF tutorials. 3 - Yes memoryChannelLayer setting is not for Redis - you need to change that setting to work with your Redis application on Windows (You are very brave using Redis on Windows 👍) 4 - In-memory channel layers operate each process as a separate layer, which means no cross-process messaging is possible. As the core value of channel layers to provide distributed messaging, in-memory usage will result in sub-optimal performance and data-loss in a multi-instance environment.
Great tutorial! I get an error message ImproperlyConfigured: Cannot import ASGI_APPLICATION module ‘chat.routing’ I’ve been searching for solutions every where but I can’t find any that’ll fix it. Do you have any solutions for it? Thanks! 🙏🏻❤️
It should be ok as a starter. Just make sure you use the identical versions of the packages in the tutorial. If you follow the tutorial, maybe first, then update the code based on newer framework versions.
Very powerful statement there Manu, its ok - I really don't enjoy listening back - but I hope that there is something to learn here. Like Aashay suggests - this is Django next level - but translated - a little bit more interesting and fun 😂
Thank you for the tutorial. What is the best approach to integrate a database in chat application giving the fact that database is syncron app and chat channels asyncron? Syncron channels with db or asyncron channels with syncron-to-asyncron connection db? Thank you.
Hi Mihai, sorry for the delay - I was thinking about this one in bed last night. When you say the best way. Could you give me some examples of different approaches you were thinking of?
This is a great tutorial video. I just have a couple of issues. Every time I type in from channels.auth import AuthMiddlewareStack it gets highlighted yellow and it says that import packages is missing. What can I do to resolve the issue?
Just a couple of questions, how would I add a second chat room? And, let’s say I wanted the user to be able to change chat rooms by typing something like “change room + room name”. How what that be done? Essentially, how do you make the app react to certain kinds of input? I’m decently familiar with Python but I’m still new to Django. Thanks!
Hi Josh, good questions - but it needs to be replied with a tutorial. I will get rid of this one and - as there is a lot of requests for this type of feature will build it all
After the explanation I am not sure I understand exactly why we are using asynchronous code as opposed to synchronous. Does it make a difference in a chat app?
Hi Layers. Synchronous - send data in one direction at a time. We send data (we wait for reply) we do nothing else until we get a reply. Asynchronous - send data and retrieve data at same time. We send data and do some other things then we might get a reply at some point. The point is here in chat. Imagine we both go to the chat room. I add a message and press send. You are not going to get that message until you refresh the page - when you refresh the page you send a message to the server asking for any latest messages - the server gives you the data. So - until you refresh you are not going to get my message. Working asynchronously - when you go into the chatroom now your browser is always waiting for data (new messages) and will show you then automatically - so now when I type a message and send you get it instantly.
@@veryacademy isn't that what the websocket does? Async code just runs on different threads so it doesn't hold up the queue, allowing for multiple actions. I've seen several examples of chat rooms with channels 3 that did not use async code.
channels.readthedocs.io/en/latest/tutorial/part_2.html In this tutorial on the official Django documentation page they are using a synchronous consumer to achieve the same thing.
yea to low on detail but I had a similar issue you might want to 1: no need create a new routing file but stick with the pre made asgi.py and update it just go to the documentation and read the installation guide, 2: are you sure there is not an error above that says there is an error in the routing.py file you might want to fix that if there is, 3: make sure they are all in the same folder I had to store everything in the core folder and not the app because I couldn't import it right and it worked. hope this helps
@@shwetapandey2333 again no detail but you can always switch to node js cuz it’s a better language anyway and it’s faster and it has a bigger community so more libraries and better integrations with other stuff
is there any ways to send a user avatar through the websocket or is there any other ways to show not only username but also user avatar that you built in your videos. I think it can send avatar url as the way to send username in this video. I don't know how it would work in production.. Thanks always appreciate your effort!
really cool, thank you. What would one use to create a private messaging app in django though? like being able to add a friend and chat to them 1 on 1?
Hi Createlyf, it is possible to use AJAX in this scenario but as you suggest, you would most probably need to periodically send AJAX requests in order to create a functional real-time chat application. Once you start scaling this type of approach you are sending a lot of requests to the server - there are other and better approaches that you could use.
hi so great video tutorial i have a error plz help my WebSocket connection to 'ws://127.0.0.1:8000/ws/chat/asdasd/' failed: Error during WebSocket handshake: Unexpected response code: 500
I thought this could be a good project to be done, but know I'm doing something more complex, so I would really like to have a complete course using consumers, routing, channels and that stuffs maybe if someone has something like that I would really aprecciate the help
Sorry cant really give you a good answer here. It does give you clues in the error with regards to the on argument. You need to try and follow that lead. Its just going to be something really simple if you are following the code example.
@Very Academy Hi there, love your content. I wonder if you have any suggestion how I might integrate voice reecording when the chatroom is deployed on mobile. My scenario is a market research app where a chatroom will purely be between one user and the server, and i want to give the user the option of pressing "record", recording a voice memo, and having that upload to the server. Tips very much appreciated!
Best I can suggest here. Assuming you mean webapp viewed on a mobile. Django supports a file field. I would imaging some JavaScript capturing audio and passing over to django saving in a filefield in the db. docs.djangoproject.com/en/3.1/ref/models/fields/ github.com/collab-project/videojs-record 👍
@@veryacademy Hi, yes, you're right, it will be a standard webpage, but viewed on mobile, obviously with appropriate responsiveness. Thanks so much for your reply, I'm going to check that out.
I wanted to know very much is building a platform like WeChat possible,like WeChat with all it's features.and can there pls,pls be a tutorial for it pls i would be grateful
It's not a very great way to let the client send the username to the chat room, as they might claim to be someone else. How do I get that done on the server-side?
Hi Shubham, This tutorial just represents me starting to think about how best to deliver this type of content and get an idea of the interest. There are many many flaws to this and is nowhere near a useable product. I will follow this up in the future with something much more comprehensive.
Yes definitely, we have barely started it. I originally said I would wait for Django 4 which will give us more tools for this type of work. I will put together and run a project beforehand if you like. Can you give me any inspiration? Shall I continue chat or do something else?
@@veryacademy Django 4 is still far away... I recommend you to create Playlists based on Project or App using Django stack. Django stack here means : Django + DRF + React + Redux + Django Channels + Redis + Postgres + Heroku + anything necessary depends on the project or app that you gonna build and share to others in this awesome channel. I've seen lot of React + Firebase to create app clones, but still rare that use Django stack for real time app. Especially combined with Front End Framework like react. I love Django, and I believe Django + React is something beyond any web stack, in the future (it's the best combination I think). I've watched some of your videos in this channel, the topics are very interesting, since I'm beginner to Django and stuff. I really interested to watch. But I have feedbacks for you. 1. Please Make App Clones from Django Stack (as I mentioned above). You can start for example : - Blog using Django Stack (with react etc , as I mentioned above) - Search Engine - Social Network - Chat - Video Chat/Voice Chat - E-Commerce - Project Management Tools like Jira - Human Resource Management - IOT project - Computer Vision - AI Personal Assistant - Data Science - Machine Learning - or something else I believe it doesn't have to be complex (even though using all stack might look overkill, but what we need to know is the function for each stack in a whole), simple but fully functional it's good enough. So we can deploy it to Heroku or somewhere else that good for Django Stack (maybe kubernetes, I don't know, I'm still learning though). 2. Keep each video simple (for example, Video 1 - How to setup Django Video 2 - How to bla bla bla) Don't create 1 hour long video, hard to learn that way, especially when I want to learn specific part or topic. Short Videos with Sub Explanation (like in this video, I'm aware that youtube has feature to naming Parts of the video on red line play video. But instead using it for separating parts, you can use it for Sub Explanation. For example: How to install Django 0-1 min - Go to django website and install Django How to create virtual environment for Django 0-1 min - Creating directory on windows 1-2 mins - creating virtual environment and more. Make each video explanation to the point, don't confused it with jargons. If you want to do something, then you have to do this, etc. 3. Create Videos for Project that are ready to use for production (final video should be how to deploy video). Because after we follow along the tutorial, invested time to watch, we want the project to be ready to use, not give us things to tinker again. I mean, Imagine that we watched tutorials, and in the end, we can't use the project to production. 4. I believe Django + React is the future for web stack. I'm learning hard to master these things. So, if you create those things (in your way of course, I don't force you to create it as I said, I only recommend it), I believe it would help all Django Beginners like me. * fyi, I bought some courses on online learning websites, but some of those courses not good, because I paid for courses that I can't finished. I lost interest on the way, around 15-60% content of the course that I watched. The content just too long and boring, and not really useful for the final project that we learned at the end of the course. I started web development using vanilla HTML, CSS, JS, BOOTSTRAP, PHP, on Linux NGINX before, then when I started learning Django, I feel it would be a future of web stack. Especially when combined with React. Look forward to see it. Hope you consider my recommendations. Thankss! Good luck!
Hello, I am having a long error lines while I tried to install channels with pip when It comes to install twisted , occuring an error please anybody can help me with that?
Hello 123sid789. You will no doubt come across the use of regular expressions. I did this to support and expand learning - I backed this up with a tutorial explaining them enough to understand this particular case: ua-cam.com/video/Ws-2gB1w37Q/v-deo.html
Manu, anything is possible, as per normal. I will do the next part today, show you how to initially deploy it on the server. Its not the kindest experience deploying something like this for new devs.
What I am thinking is that I want to explore Vue/React with this technology to build something interesting. I was thinking of cloning the facebook inbox page. But of course we can move away from chatrooms - many more interesting ideas. We will eventually end up doing more machine learning as well I would imagine. As per normal many great adventures, little time.
@@veryacademy Yes! Integrating with react would be great. There is a not lot of content on UA-cam integrating react & django channels. One is there from JustDjango but it's little difficult to follow and its outdated. Because it's all class based component and no react hooks is used.
I keep getting this error when I try to use channels TypeError: __call__() missing 2 required positional arguments: 'receive' and 'send'. Seems like a lot of folks who have tried to install channels have received this error. Did you face this issue? If not, really curious as to why
It's quite difficult to give a reason as to "why" when it *didn't* happen. Have you tried downgrading or upgrading your python version? I'm running 3.7 and it's fine. Twister can't be installed on 3.9 so far, for example.
This tutorial is by far THE BEST Django Channels tutorial I have encountered. This provides the greatest step by step direction and clarity. Thank you!
Thanks Marc, hopefully this is just the beginning. Just need to get this channel making a little more and I will just make tutorials 24/7. There is so much more quality I can add to these tutorials - great to hear you think its the best!
Ok, I have looking for a source to learn about Django Websocket for the whole week and this video truly saved my ass. Any other videos altho may has more views but just kinda rush into the tutorial without explaining anything. This video is super informative and great explaination.
Your channel is a gem. Thank you so much. Keep up the great work.
Thank you 👍
Yay! Channels takes django to next level. Thank you so much for this.
Could you please show us how to deploy this as well.. Because I've not seen any good content on deploying channels to a production grade server. If you're making any series on this that would be a great content.
Loving all your Django content. Keep up the good work. And again, thank you so much 🙏🏼
I will do an initial deploy to Heroku up next so that folks can get a look at using Redis. Do you have any deployment preferences?
@@veryacademy Nginx with uvicorn/daphne would be great. Thanks 😊
@@veryacademy if we're having a series on django channels another idea for this series would be, processing a huge file in background using Celery and giving real time updates in a progress bar or something. Since channel has an option to subscribe to a particular group and send updates using channel layers.
@@veryacademy Yaaaa🔥🔥🔥🔥
sir i love you so much you just thought me the thing ive been strugling to learn, your teaching method is abslote gold may god bless you please do more tutorial we need you
duuude you are on your way to save me in my current project at school! We are doing this way too advanced project, and this is just what I needed
If your doing this at school - you have a great teacher. Most teachers can’t even work PowerPoint
@@veryacademy We have a subject called Digital Design and Development, where we are creating websites. Though I have never used Django before, I have programmed for a long time. Yeah Denmark has really nice subjects, but I cannot get the part of printing hello world on the website to work. Must be a mistake somewhere. I must take a look when I return to two screens instead of one.
@@veryacademy Oh, and I basicly learn all this myself, since it has never been a requirement for the subject, I just found it interesting and useful
This is gold. The best tutorial. Keep em coming
Thanks, will do!
This is really brilliant work that you're doing. Thank you!
Glad you enjoy it! Thank you! 👍
I really felt that I've learned and accomplished something at the end of the video, thank you!!!
Thank you so much!! You are the best Django teacher... Gaining alot from you
Happy to hear that!
Big thanks to this channel for making such beautiful content, After watching this video documentation is so easy to understand.
another excellent Django tutorial, and you so appreciated by the Django Community......
Hey! This is amazing! Thank you so much! Could you please advise in what order should a beginner watch all your playlists to gain complete knowledge and become proficient in Django? Just a piece of advice you can make a short video of this or mention it in any of your upcoming videos. Lastly, thanks again for creating these videos and making them available to global users for free.
that was really helpful for me .
you are serving such a brilliant service to us
Thanks a lot
You just gained a sub!
👍
Great work for a boilerplate, THANK YOU.
Our pleasure!
Dude you deserve million subs!!
That seems like a long way off at the moment, but hopefully one day!
@@veryacademy haha for sure homie. A quick suggestion though: It would really help alot if you could make a React beginner series
Efforts appreciated! man ur just terrific. i cant thank you enough how easy u made me to understand.
You, sir, are a great teacher! Thank you :D
You're very welcome! 👍
Thank you for the tutorial!! Helped a lot
Thank you so much for this amazing lecture! I loved your explanation about project specifications and concepts.
really amazing, I would like to see more tutorials
tq so much it just works fine
I will be swinging back to this soon and updating it with a full on system (I say soon - maybe 8 weeks or so) 👍
Great video man! Really helped me. Thanks a lot
Glad it helped! Hopefully will get around to updating this with more features sooner than later
Explained very beautifully, Thank you 🙏
Every time I see it for building the project, I fell asleep in just a few minutes. Is it only me or its his voice that make me feel sleepy.
Don't forget about ChatRoomConsumer.as_asgi() in websocket_urlpatterns if you have problem like: TypeError: __call__() missing 1 required positional argument: 'send'
GL!
👍
@@veryacademy Thank you for the amazing guide. Very detailed! You have helped me a lot!
You really helped me, thanks!
respect from heart for you man
You are more than welcome
I was looking for this..thank you 😁
No problem 😊
Very nice tutorial 🙏 thanks please do more videos to help us
More to come!
really awesome tut. Thank u
You're welcome!
thank you so much. Really useful
Glad it was helpful!
Learned a lot.
Feedback: Wish there was a bit more clearer explanation about how the routing is taking place, how the consumers is being talked to and is talking with. Code wise it was great, but I got lost plenty and had to look up the docs for an "overview" of the concepts.
First time building a Django app and I could see prerequisite Django knowledge would be beneficial for this project.
Music to my ears - if you got lost and looked it up that means I have done what I set out to do 👍
@@veryacademy haha touché
@@veryacademy I'm having an issue. around the 1:11:00 mark, we we add the chatroom view's html, and javascript for opening up a websocket. I'm getting a handshake failure and 500 error. THe docs says that should happen due to not having a consumer, but in this tutorial we had already built the consumer. So i'm not sure why the error is happening. Pls help.
btw the error is: TypeError: object.__init__() takes no parameters, from websocket.py. I've spent a few hours to fix this, not sure of the issue.
@@veryacademy 2 hours later, figured it out. To anyone having this same error: I forgot to append ".as_asgi()" to "consumers.ChatRoomConsumer", so it should have been "consumers.chatRoomConsumer.as_asgi()"
In your code given above, as_asgi() was missing from your code in this context. So not sure how it worked, or if you added behind the scenes, please confirm with me.
Such a great tutorial. Thank you so much
You are so welcome!
Amazing tutorial.
your voice sounds like the net ninja.
Thanks Jack 😂 I guess that cant be a bad thing 👍
really awesome course sir
Brilliant absolutely Brilliant 👍
👍
is there ANY way to integrate real time communication in a WSGI server?
Amazing thank you very much and keep going
Thank you so much for this... I'm still running into this "cannot import ASGI_APPLICATION module..." Error though, what can I do?
Thank you for this
You're so welcome!
Thank Thank Thank Thank Thank Thank Thank Thank Thank Thank Thank you 💖💖💖💖💖💖💖💖
Thank you sir...this is what I needed 😊 please also teach us how to deploy this - many thanks 👍
Recording it right this second!
can we also a Direct Message tutorial? its would complete the series. many thanks for your great efforts and work
hii i have probleme connecting to the websockets i did everything you showed on the vid i just cant find the issue
WebSocket URL: Verify that you have the correct WebSocket URL. It should start with either "ws://" or "wss://" (for secure connections). Ensure that the URL includes the correct hostname, port number, and any additional path or query parameters required.
@@veryacademy updates ? I have the same error. i vaeified all of that
To save someone else the trouble make sure to use channels version 3.0.5
A very good tutorial. Thank you very much. Is there another video to save the data in the database? Your last videos unfortunately continue with other topics.
Furthermore it would be interesting to know how to restrict the chatroom for example for 2 users (private chat).
Hi Osmanio - really sorry I stopped this run of tutorials, at least for now - the community members were asking for more DRF that is why I concentrated all my efforts on that. I do want to come back to this and do exactly that and expand on this more to make it a little more feature rich.
so i have a question, When we are using websocket and Channels we don't store data in the database using Models? and is it that we have to use consumer, routing and the template always?
28:30 ran into so many errors with the tutorial and trying to get it fixed as I code it's definitely frustrating!!!
please add requirements.txt that has the package versions,
That's a lot of debugging if we don't have similar packages which was used in this project will provide a lot of help
thank you. you are amazing
Great work. could we also include "The video chat option"
This tutorial has been one of the most popular on the channel. I am making 2-3 more courses and then will be building a whole course on this topic.
@@veryacademy Will surely follow it
Sir, can you make a full-video on django channels like saving messages or something like that.
Hi, great tutorial!
Question: Why do i have to / what's the benefit of including my own app ("chat" in this case) to installed apps ?
I thought the settings would list all apps that are installed into my own app ?
I haven't listed my own app so far and haven't noticed any difficulties so im wondering what it does
Hi Surinam, if you are referring to INSTALLED_APPS in settings. By adding your app to the list allows your app and Django to interact with each other in certain situations. For example working and interacting with databases. Here is the manual reference docs.djangoproject.com/en/3.0/ref/applications/ Any other questions please just ask.
@@veryacademy Yeah, i did that sooo much earlier in my project that i forgot that i added it haha
hi sir ,you saved my time best video about channels, thanks lot,
i have some doubts
1.this chat application we can put our existing project ?
2.any difference in while deployment time?
3. i am previously using redis on windos 10 but not working then i used channels.layers.InMemoryChannelLayer
4 in production we use inmemorychannel layer
Hello, 1 - yes indeed you can put it into an existing project - sorry I cant really be anymore specific here. 2 - Yes I think I did make a tutorial where we deployed it - this is just a really basic example - I will revisit this series once we have established more DRF tutorials. 3 - Yes memoryChannelLayer setting is not for Redis - you need to change that setting to work with your Redis application on Windows (You are very brave using Redis on Windows 👍) 4 - In-memory channel layers operate each process as a separate layer, which means no cross-process messaging is possible. As the core value of channel layers to provide distributed messaging, in-memory usage will result in sub-optimal performance and data-loss in a multi-instance environment.
Great tutorial!
I get an error message ImproperlyConfigured: Cannot import ASGI_APPLICATION module ‘chat.routing’ I’ve been searching for solutions every where but I can’t find any that’ll fix it. Do you have any solutions for it?
Thanks! 🙏🏻❤️
did you find any solutions for it ? i have the same problem
Make sure to use the same django 3.1.1 version as in tutorial.
Read the error log carefully, their must be an error before 'chat.routing'.
hello can i still use this guide because i saw some changes in the documents of channels like " python -m pip install -U 'channels[daphne]' "
It should be ok as a starter. Just make sure you use the identical versions of the packages in the tutorial. If you follow the tutorial, maybe first, then update the code based on newer framework versions.
hii did ur code work?
I am getting an error Not Found: /ws/chat/aaaa/
Mind-blowing 👌
Very powerful statement there Manu, its ok - I really don't enjoy listening back - but I hope that there is something to learn here. Like Aashay suggests - this is Django next level - but translated - a little bit more interesting and fun 😂
is this more scalable and less costly when deploying than using firebase realtime db with a mobile chat app?
Thank you for the tutorial. What is the best approach to integrate a database in chat application giving the fact that database is syncron app and chat channels asyncron? Syncron channels with db or asyncron channels with syncron-to-asyncron connection db? Thank you.
Hi Mihai, sorry for the delay - I was thinking about this one in bed last night. When you say the best way. Could you give me some examples of different approaches you were thinking of?
This is a great tutorial video. I just have a couple of issues. Every time I type in from channels.auth import AuthMiddlewareStack it gets highlighted yellow and it says that import packages is missing. What can I do to resolve the issue?
can i combine this backend to a swift frontend ? (for ios development)
Yes 👍
Just a couple of questions, how would I add a second chat room? And, let’s say I wanted the user to be able to change chat rooms by typing something like “change room + room name”. How what that be done? Essentially, how do you make the app react to certain kinds of input? I’m decently familiar with Python but I’m still new to Django. Thanks!
Hi Josh, good questions - but it needs to be replied with a tutorial. I will get rid of this one and - as there is a lot of requests for this type of feature will build it all
After the explanation I am not sure I understand exactly why we are using asynchronous code as opposed to synchronous. Does it make a difference in a chat app?
Hi Layers.
Synchronous - send data in one direction at a time. We send data (we wait for reply) we do nothing else until we get a reply.
Asynchronous - send data and retrieve data at same time. We send data and do some other things then we might get a reply at some point.
The point is here in chat. Imagine we both go to the chat room. I add a message and press send. You are not going to get that message until you refresh the page - when you refresh the page you send a message to the server asking for any latest messages - the server gives you the data. So - until you refresh you are not going to get my message. Working asynchronously - when you go into the chatroom now your browser is always waiting for data (new messages) and will show you then automatically - so now when I type a message and send you get it instantly.
@@veryacademy isn't that what the websocket does? Async code just runs on different threads so it doesn't hold up the queue, allowing for multiple actions. I've seen several examples of chat rooms with channels 3 that did not use async code.
channels.readthedocs.io/en/latest/tutorial/part_2.html In this tutorial on the official Django documentation page they are using a synchronous consumer to achieve the same thing.
I did everything step by step. However, the http does not get upgraded to a websocket. How could this be explained? Looking forward to any help :)
Hi Jonas, hey this can be a real pain if you don't get everything lined up. Have you tried the code I provided or are you just building your own?
any updates? I am having the same error
@@veryacademy I tried building on my own but got same error
I'm having issues with routing.
"Cannot import ASGI_APPLICATION module 'core.routing'"
Stuck at the around 40 minute into the video.
yea to low on detail but I had a similar issue you might want to 1: no need create a new routing file but stick with the pre made asgi.py and update it just go to the documentation and read the installation guide, 2: are you sure there is not an error above that says there is an error in the routing.py file you might want to fix that if there is, 3: make sure they are all in the same folder I had to store everything in the core folder and not the app because I couldn't import it right and it worked. hope this helps
i am facing similar issue
@@shwetapandey2333 again no detail but you can always switch to node js cuz it’s a better language anyway and it’s faster and it has a bigger community so more libraries and better integrations with other stuff
before starting
are you also doing the markup and css styling in the project?
please answer anyone
It is just a showcase for Django rather than actually doing styling etc - so I think the answer is no
@@veryacademy i have to make the project for my college so i can refer for django part to this video and style my project on my own. is that correct?
Yep, that’s right
@@veryacademy okay thanks a lot.
THANK YOOOOU SOOO MUUUUUCH
is there any ways to send a user avatar through the websocket or is there any other ways to show not only username but also user avatar that you built in your videos. I think it can send avatar url as the way to send username in this video. I don't know how it would work in production..
Thanks always appreciate your effort!
stackoverflow.com/questions/41492493/django-channels-file-image-upload
really cool, thank you. What would one use to create a private messaging app in django though? like being able to add a friend and chat to them 1 on 1?
This is a very high quality content. Congratulations!! BTW Whats the best way to receive messages from a mqtt broker using django channels?
Thank you for the tutorial.. Is it possible to replace Ajax requests with websockets? If so will it be efficient?
Thanks
Hi Createlyf, it is possible to use AJAX in this scenario but as you suggest, you would most probably need to periodically send AJAX requests in order to create a functional real-time chat application. Once you start scaling this type of approach you are sending a lot of requests to the server - there are other and better approaches that you could use.
Great series to learn async views in Django. Thanks alot.
Hey Pabor, yeah it is a little more exciting using async and does open lots of great potential for learning more exciting apps
is there anyway to implement 1 to 1 chat in django without the chat room?
please make projects on Shipping management system in django
Thats a good idea - thank you
I'm getting an error that socket could not connect. I downloaded the repo from you but even that shows the same error.
I can't establish the web socket as well. The routing can not find the /ws/chat/....
Thank you for your awesome? tutorials is this ready to deploy to production
Not at all unfortunately
hi so great video tutorial i have a error plz help my
WebSocket connection to 'ws://127.0.0.1:8000/ws/chat/asdasd/' failed: Error during WebSocket handshake: Unexpected response code: 500
updates ? I have the same error
I thought this could be a good project to be done, but know I'm doing something more complex, so I would really like to have a complete course using consumers, routing, channels and that stuffs maybe if someone has something like that I would really aprecciate the help
Keep an eye on the channel, I have been busy the past 4 weeks building and recording this project. ETA is 2-3 weeks.
After handshaking, I got this error. TypeError: object.__init__() takes exactly one argument (the instance to initialize) .Then disconnecting
Sorry cant really give you a good answer here. It does give you clues in the error with regards to the on argument. You need to try and follow that lead. Its just going to be something really simple if you are following the code example.
@@veryacademy I solved the issue by editing in the routing.py in the app. There I added consumers.ChatConsumer.as_asgi()
@@rashid_vp thanks a lot!!
@@rashid_vp Many thanks for this fix, I had the same issue, and it was driving me round the bend!
@@rashid_vp thank god you found this. How would it work in his tutorial, but not for us?
@Very Academy Hi there, love your content. I wonder if you have any suggestion how I might integrate voice reecording when the chatroom is deployed on mobile. My scenario is a market research app where a chatroom will purely be between one user and the server, and i want to give the user the option of pressing "record", recording a voice memo, and having that upload to the server. Tips very much appreciated!
Best I can suggest here. Assuming you mean webapp viewed on a mobile. Django supports a file field. I would imaging some JavaScript capturing audio and passing over to django saving in a filefield in the db. docs.djangoproject.com/en/3.1/ref/models/fields/
github.com/collab-project/videojs-record 👍
@@veryacademy Hi, yes, you're right, it will be a standard webpage, but viewed on mobile, obviously with appropriate responsiveness. Thanks so much for your reply, I'm going to check that out.
What's the front-end and Back-end of this project
I wanted to know very much is building a platform like WeChat possible,like WeChat with all it's features.and can there pls,pls be a tutorial for it pls i would be grateful
can you make this with WebSockets & DRF
It's not a very great way to let the client send the username to the chat room, as they might claim to be someone else. How do I get that done on the server-side?
Anyway, very useful tutorial.
Hi Shubham, This tutorial just represents me starting to think about how best to deliver this type of content and get an idea of the interest. There are many many flaws to this and is nowhere near a useable product. I will follow this up in the future with something much more comprehensive.
@@veryacademy Great, keep up the good work!
can anyone share the exact code for base.html which is used here.
Thank you sir
Will there be other tutorials about Django Channels again?
Yes definitely, we have barely started it. I originally said I would wait for Django 4 which will give us more tools for this type of work. I will put together and run a project beforehand if you like. Can you give me any inspiration? Shall I continue chat or do something else?
@@veryacademy Django 4 is still far away...
I recommend you to create Playlists based on Project or App using Django stack.
Django stack here means :
Django + DRF + React + Redux + Django Channels + Redis + Postgres + Heroku + anything necessary depends on the project or app that you gonna build and share to others in this awesome channel.
I've seen lot of React + Firebase to create app clones, but still rare that use Django stack for real time app.
Especially combined with Front End Framework like react.
I love Django, and I believe Django + React is something beyond any web stack, in the future (it's the best combination I think).
I've watched some of your videos in this channel, the topics are very interesting, since I'm beginner to Django and stuff.
I really interested to watch.
But I have feedbacks for you.
1. Please Make App Clones from Django Stack (as I mentioned above).
You can start for example :
- Blog using Django Stack (with react etc , as I mentioned above)
- Search Engine
- Social Network
- Chat
- Video Chat/Voice Chat
- E-Commerce
- Project Management Tools like Jira
- Human Resource Management
- IOT project
- Computer Vision
- AI Personal Assistant
- Data Science
- Machine Learning
- or something else
I believe it doesn't have to be complex (even though using all stack might look overkill, but what we need to know is the function for each stack in a whole), simple but fully functional it's good enough. So we can deploy it to Heroku or somewhere else that good for Django Stack (maybe kubernetes, I don't know, I'm still learning though).
2. Keep each video simple (for example, Video 1 - How to setup Django
Video 2 - How to bla bla bla)
Don't create 1 hour long video, hard to learn that way, especially when I want to learn specific part or topic.
Short Videos with Sub Explanation (like in this video, I'm aware that youtube has feature to naming Parts of the video on red line play video. But instead using it for separating parts, you can use it for Sub Explanation.
For example:
How to install Django
0-1 min - Go to django website and install Django
How to create virtual environment for Django
0-1 min - Creating directory on windows
1-2 mins - creating virtual environment
and more.
Make each video explanation to the point, don't confused it with jargons.
If you want to do something, then you have to do this, etc.
3. Create Videos for Project that are ready to use for production (final video should be how to deploy video). Because after we follow along the tutorial, invested time to watch, we want the project to be ready to use, not give us things to tinker again. I mean, Imagine that we watched tutorials, and in the end, we can't use the project to production.
4. I believe Django + React is the future for web stack. I'm learning hard to master these things. So, if you create those things (in your way of course, I don't force you to create it as I said, I only recommend it), I believe it would help all Django Beginners like me.
* fyi, I bought some courses on online learning websites, but some of those courses not good, because I paid for courses that I can't finished. I lost interest on the way, around 15-60% content of the course that I watched.
The content just too long and boring, and not really useful for the final project that we learned at the end of the course.
I started web development using vanilla HTML, CSS, JS, BOOTSTRAP, PHP, on Linux NGINX before, then when I started learning Django, I feel it would be a future of web stack.
Especially when combined with React.
Look forward to see it. Hope you consider my recommendations. Thankss!
Good luck!
@@hansalexander1051 Hey there, how is it going
Did you make some of those projects?
Hello, I am having a long error lines while I tried to install channels with pip
when It comes to install twisted , occuring an error
please anybody can help me with that?
Why didn't you use path instead of re_path in the consumers.py file?
Hello 123sid789. You will no doubt come across the use of regular expressions. I did this to support and expand learning - I backed this up with a tutorial explaining them enough to understand this particular case: ua-cam.com/video/Ws-2gB1w37Q/v-deo.html
@@veryacademy Thanks for the response. Looking forward to many more videos in this series. Great stuff.
No problem, any more questions please just ask!
Make a video for one user to another one user chatting with django web socket
No problem.
anyone plz help me to resolve this error -
raise ImproperlyConfigured("Cannot import ASGI_APPLICATION module %r" % path)
django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'healthscape.routing'
Our boi here basically taught us how to build Omegle. . . … ..
Is it possible to send attachments also? How can we Implement? can you take this series further?
Manu, anything is possible, as per normal. I will do the next part today, show you how to initially deploy it on the server. Its not the kindest experience deploying something like this for new devs.
What I am thinking is that I want to explore Vue/React with this technology to build something interesting. I was thinking of cloning the facebook inbox page. But of course we can move away from chatrooms - many more interesting ideas. We will eventually end up doing more machine learning as well I would imagine. As per normal many great adventures, little time.
@@veryacademy Yes! Integrating with react would be great. There is a not lot of content on UA-cam integrating react & django channels. One is there from JustDjango but it's little difficult to follow and its outdated. Because it's all class based component and no react hooks is used.
@@veryacademy Okay. my suggestion go with react.
@@aashayamballi +1
I keep getting this error when I try to use channels TypeError: __call__() missing 2 required positional arguments: 'receive' and 'send'. Seems like a lot of folks who have tried to install channels have received this error. Did you face this issue? If not, really curious as to why
It's quite difficult to give a reason as to "why" when it *didn't* happen. Have you tried downgrading or upgrading your python version? I'm running 3.7 and it's fine. Twister can't be installed on 3.9 so far, for example.
I am facing this issue ,😒 and i am stop watching this video
I got errors when installing channels.
Installing collected packages: twisted, daphne, channels
Running setup.py install for twisted ... error
ERROR: Command errored out with exit status 1:
Advise please. Thanks.
Note:
Python 3.8.5
Django 3.1
Have a look at the comments made by createlyf see if that helps you.
@@veryacademy Solved it.. thanks
@@hansalexander1051 Nice one!
django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'core.routing' / how can i solve this
Hi, did you solve this problem?
@@helloworld2831 Unfortunately i didn't
Will it work im using mySQL database
I followed the tutorial twice but was unable to get it working on linux using firefox :(
raise KeyError(key) from None
KeyError: 'REDIS_URL'
got this error.
doesn't work on windows in latest django version.
Interesting, is it working with the version specified in the tutorial?