Answer the question
In order to leave comments, you need to log in
How can I work with WebSockets?
Good evening.
I am writing an admin panel on Vue + Django, the data that comes from the site itself should appear dynamically in the panel.
They communicate via WebSocket, how can I track the creation of a new object in the database, and then kick the WebSocket?
Is it possible to do this through signals? Didn't find an implementation* A
POST request flies from the site, which creates a new object in the database, after which I need to immediately display this object in the admin panel.
Also, what can I use as the first argument when creating a group?
await self.channel_layer.group_add(
self.?,
self.channel_name
)
Answer the question
In order to leave comments, you need to log in
Yes, it turns out - https://django.fun/tutorials/django-websockety-ic...
PS...
One of the options is to give json and work through ajax. Immediately after sending the object via ajax, it requests the re-updated data, also via ajax. And yes, in this case, little is left of Django itself, except for ORM :-)
The second option is to install an independent websocket application where to shove data from the backend, and already pick it up at the front.
For as I remember, django does not know how to use websocket, but I could be wrong.
The third option - do you need django if vue is running on the front? Maybe immediately on aiohttp?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question