简体   繁体   中英

How to display messages in a chat application in Django

I am building a chat application in Django. But I am confused about how to show messages as soon as the person on the other side sends a message. At present, I have to reload the page to view the messages. I thought of refreshing the page automatically for 3-5 seconds. Is there any way to display messages as soon as the other person sends a message

You need to use websockets to obtain such type of applications. Web sockets maintain a link with your server and when ever there is a change in server the user gets notified automatically without refreshing.

You should use websockets to accomplish this. The library to go is django channels ( https://channels.readthedocs.io/en/latest/ ) and in their example they also build a small chat application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM