python - Show more information about ManyToMany field? -
i use django-reversion app in project.
i have modal "task" manytomany field "comments". in project have page revertions list. , shows me in comments field id of comments. for example: comments (field_name): [66, 67, 68] (field_value).
what best way take id-s , show comment information (author, text, created) not id. possible? little bit comfused.
models.py:
@reversion.register() 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)
views.py:
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)
task_reversions.html:
{% field_name, field_value in version.field_dict.items %} {{ field_name }} {{ field_value }} {% endfor %}
Comments
Post a Comment