1

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

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Liran thanks for the link, it did help and after going through the articles a few times I am slowly starting to get it.
1

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

2 Comments

Hi Ken, it was kinda dumb of me, socket is after all a socket based communication, what will matter is serialising and deserialising at the end points based on the data formats being used. Thanks for reminding me. Can I mark both the posts as answers? :) Does SO allow that?
@Subbu unfortunately you can't. But you can upvote both answers and mark the one you feel gave you the most valuable information regarding your question as answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.