diff --git a/apps/back/consumers.py b/apps/back/consumers.py index 7e5366b..cb6a15d 100644 --- a/apps/back/consumers.py +++ b/apps/back/consumers.py @@ -7,20 +7,11 @@ class BlogConsumer(WebsocketConsumer): def connect(self): ''' Cliente se conecta ''' - # Recoge el nombre de la sala - self.room_name = self.scope["url_route"]["kwargs"]["room_name"] - self.room_group_name = "blog_%s" % self.room_name - - # Se une a la sala - self.channel_layer.group_add(self.room_group_name, self.channel_name) - - # Informa al cliente del éxito self.accept() def disconnect(self, close_code): ''' Cliente se desconecta ''' - # Leave room group - self.channel_layer.group_discard(self.room_group_name, self.channel_name) + pass def receive(self, text_data): ''' Cliente envía información y nosotros la recibimos ''' @@ -39,7 +30,7 @@ class BlogConsumer(WebsocketConsumer): data['pag'] = pag if template == "partials/blog/single.html": - data["post"] = Post.objects.get(data['id']) + data["post"] = Post.objects.get(pk=data['id']) # Send message to WebSocket self.send( diff --git a/apps/back/migrations/0004_auto_20210312_1939.py b/apps/back/migrations/0004_auto_20210312_1939.py new file mode 100644 index 0000000..5709f1f --- /dev/null +++ b/apps/back/migrations/0004_auto_20210312_1939.py @@ -0,0 +1,21 @@ +# Generated by Django 3.1.7 on 2021-03-12 19:39 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('back', '0003_auto_20210309_2038'), + ] + + operations = [ + migrations.AlterModelOptions( + name='comment', + options={}, + ), + migrations.AlterModelOptions( + name='post', + options={}, + ), + ] diff --git a/apps/front/templates/partials/blog/single.html b/apps/front/templates/partials/blog/single.html index 95ef4d9..3d21b39 100644 --- a/apps/front/templates/partials/blog/single.html +++ b/apps/front/templates/partials/blog/single.html @@ -2,4 +2,4 @@