Reputation: 618
I am working on a django based project where we now intend to add some realtime capabilities to send data to the connected clients and refresh the UI as and when required. The framework being used to build the frontend is Angular6 and we are kinda new to Angular.
I know how to use channels to send and receive data. But, even after considerable searching, I am still unable to find any good material on how to setup and make an Angular app consume the data thrown by the django channels.
In a nutshell how to make djangochannels and an angular app work together.?
What I found Already:
http://devarea.com/angular-and-django-websockets-communication/#.XGwHiaIzbIU
Above link explains how to do what I want but its not clear which code goes where and what are the imports required etc.
Would be great If some one is able to explain/correct it or may be suggest a better or easier approach.
Thanks in advance
Upvotes: 1
Views: 2308
Reputation: 6296
Django channels implements the server side of the websocket protocol in a fairly generic way. So, you don't need any special Angular setup for Channels. While there is a channels js to make it easier to communicate with the websocket, the protocol is still very much the same and you can use the vanilla js websocket client. The js lib itself is deprecated since channels 2.0
So what you should really be looking for is how to implement a websocket client in Javascript if you don't already know that
Upvotes: 1
Reputation: 456
the above link is one post in a series in devarea.com.
start with this post: http://devarea.com/building-a-simple-website-with-angular-4-and-django-and-deploy-it-to-heroku/#.XG1jvi2B0iU
It covers all the steps required
Upvotes: 1