Slide 44
Slide 44 text
CHANNELS FROM OUTSIDE
CHANNELS FROM OUTSIDE
CHANNELS
CHANNELS
class Document(TimeStampedModel):
...
def save(self, *args, **kwargs):
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)(self.slug, {
'type': 'document.saved',
'message': 'document saved'
})
return super(Document, self).save(*args, **kwargs)
class DocumentDetailConsumer(DocumentListConsumer):
...
def document_saved(self, event):
do_something(event)