Django-reversion output data from a ManyToMany field?

Who faced with such a task? Use in your project app django-reversion.


Is the data model "Task" c field "comments" (ManyToMany field). In the project there is a page that displays a list of all versions of detailed information on all changes in the fields. In the comments field displayed the id of the review. For example, [66, 67, 68]. How can we bring the rest of the information about the comment (author, text, created) instead of the id?
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)
def task_reversions(request, project_code, task_code):
 project = get_object_or_404(Project, pk=project_code, status='open')
 task = get_object_or_404(GroupTask, pk=group_task_code)
 versions = Version.objects.get_for_object(ask)
 context = {
 'project': project,
 'task': task,
 'versions': versions,
 return render(request, 'project/task_reversions.html', context)

{% for field_name, field_value in version.field_dict.items %}
 {{ field_name }}
 {{ field_value }}
{% endfor %}
June 27th 19 at 15:19
1 answer
June 27th 19 at 15:21
Probably so:
{% for comment in task.comments.all %}
 {% for field_name, field_value in comment.field_dict.items %}
 {{ field_name }}
 {{ field_value }}
 {% endfor %}
{% endfor %}

You can still pre-select them using select_related()

Find more questions by tags DjangoPython