How do I transmit any changes to databases(i.e. creates and updates pertaining to a particular user) using Django Channels?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I transmit any changes to databases(i.e. creates and updates pertaining to a particular user) using Django Channels?

Alexis Candelaria
My goal is to send send any database updates to the relevant users. I was thinking of utilizing the views of the post and patch requests to do this but am not sure if there is better or more documented way. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b8810aad-de6b-4fb3-b1b6-06547d4e2d6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I transmit any changes to databases(i.e. creates and updates pertaining to a particular user) using Django Channels?

Andrew Godwin-3
Hi Alexis,

You'll need to do some work yourself - hook into database changes (either via signals or overriding the save method) to send change notifications to a different Group for each user (maybe use group names like "user-123213", where the number is their ID).

Then, when someone connects via a socket or long-poll, add their consumer to the group and listen for the change message. You can see some docs on this here: http://channels.readthedocs.io/en/latest/topics/channel_layers.html and an example of sending messages to groups (albeit from another consumer rather than a save method) here: https://github.com/andrewgodwin/channels-examples/tree/master/multichat

Andrew

On Thu, Mar 8, 2018 at 7:35 AM, Alexis Candelaria <[hidden email]> wrote:
My goal is to send send any database updates to the relevant users. I was thinking of utilizing the views of the post and patch requests to do this but am not sure if there is better or more documented way. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b8810aad-de6b-4fb3-b1b6-06547d4e2d6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFwN1uraY%3DFpWjSHy8P-UrLNWVbFAKjnFr2S5erVdNL%2B7%3DZ9Xw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.