I have task but dont know how to realise it. Any help would be appreciated!
In my django project I have modal "Task". Any task has a lot of comments. Here below you can see my code. I need to show number of new comments when user open the page. For example, when the user came out the page it was 4 comment to the task and then again after a certain time goes to a page and see the number of new comments left by other users. How to realise it? I am little bit comfused?
models.py:
class Task(models.Model):
comments = models.ManyToManyField("Comment")
class Comment(models.Model):
author = models.ForeignKey(User, on_delete=models.CASCADE)
text = models.TextField()
created = models.DateTimeField(auto_now_add=True)
html.py:
(Number of new comments: ?)
List of comments:
{% for comment in task.comments.all %}
{{ comment.author }}
{{ comment.created }}
{{ comment.text }}
{% endfor %}