0

I am pretty good at django. I have postgresql with some table and this table populated by a C++ apps. Now i want to build django app to visualize realtime basis whenever any changes occur in the database, it should update realtime in my django frontend.

I am not getting what technology to pic, I have heard of django-channel but not quite sure if i can do it with it.

This post is the purpose to get technology recommendation suggestion.

Can anyone help in this case?

4

1 回答 1

0

With channels you can to a few things:

A) Create async await based HTTP/Websocket connection handlers that can stay open for a long time.

B) send messages between these handles (or from other places) in such a way that if a handler has subscribed to a group a method on that connections handler instance will be called.

To have your connection handlers (consumers In Django speak) Get updates whenever you update the DB you can do one of 2 things.

1) When you write to the db send a message over the channel layer. 2) When your consumer connects set up a Postgres event trigger https://www.postgresql.org/docs/12/event-trigger-definition.html

(2) will let you get events whenever to DB is updated even if the code doing the update has no idea about channels. (1) on the other hand, will require all the code making changes to the db to import channels but it is more standard.

于 2020-01-29T03:02:20.187 回答