Add comments
This commit is contained in:
parent
5e4791a240
commit
42ffd59ad6
@ -1,7 +1,7 @@
|
||||
import json
|
||||
from channels.generic.websocket import WebsocketConsumer
|
||||
from django.template.loader import render_to_string
|
||||
from apps.back.models import Post
|
||||
from apps.back.models import Post, Comment
|
||||
|
||||
class BlogConsumer(WebsocketConsumer):
|
||||
|
||||
@ -31,6 +31,7 @@ class BlogConsumer(WebsocketConsumer):
|
||||
|
||||
if template == "partials/blog/single.html":
|
||||
data["post"] = Post.objects.get(pk=data['id'])
|
||||
data["comments"] = Comment.objects.filter(post__id=data['id']).all()
|
||||
|
||||
# Send message to WebSocket
|
||||
self.send(
|
||||
|
@ -1,5 +1,23 @@
|
||||
<article>
|
||||
<h1>{{ post.title }}</h1>
|
||||
<h2>{{ post.author }}</h2>
|
||||
<div>{{ post.content }}</div>
|
||||
</article>
|
||||
<div class="container grid-md">
|
||||
<article>
|
||||
<h1>{{ post.title }}</h1>
|
||||
<h2>{{ post.author }}</h2>
|
||||
<div>{{ post.content }}</div>
|
||||
</article>
|
||||
<section id="comments">
|
||||
<hr>
|
||||
<h3>Comments</h3>
|
||||
{% for comment in comments %}
|
||||
<div class="tile">
|
||||
<div class="tile-icon">
|
||||
<i class="icon icon-file centered"></i>
|
||||
</div>
|
||||
<div class="tile-content">
|
||||
<p class="tile-title">{{ comment.name }}</p>
|
||||
<p class="tile-subtitle">{{ comment.body }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
{% endfor %}
|
||||
</section>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user