Learn to use Websockets with Django by building your own ChatGPT

For the last couple months I’ve been learning about websockets and asynchronous Django. I started with what I thought was a common requirement: I wanted to build a chatbot that could stream back its responses to the user. But I was surprised to find how little information there was out there about this use case.

So, I decided to document it myself.

Lots of learning and 4,000 words later, I’m excited to share this guide with you. It touches on Django, websockets, channels, HTMX, OpenAI, and asynchronous code. I hope that if—like me—you’ve been intimidated by these technologies, it helps to make them much more accessible. Let me know if you have any questions or feedback!

5 Likes