Не получается вывести всех пользователей, которые являются owner, в шаблон. Получается только первого, одного.
models.py
class Application(models.Model):
STATUS_CHOICES = (
('In the work', 'В работе'),
('New', 'Новая'),
('Complited', 'Завершена')
)
author = models.ForeignKey(User, related_name = 'author', null = True, on_delete=models.CASCADE)
title = models.CharField(max_length=50)
text = models.TextField()
room = models.CharField(max_length = 5)
published_date = models.DateField(blank=True, null=True, default = timezone.now)
status = models.CharField(max_length=15, choices=STATUS_CHOICES, default='New')
def __str__(self):
return self.title
class Executor(models.Model):
application = models.ForeignKey('Application', on_delete=models.CASCADE)
owner = models.ForeignKey(User, related_name = 'owner', null = True, blank = True,
on_delete=models.CASCADE, limit_choices_to={ 'groups__name': 'Техническая поддержка'})
admin.py
class ExecutorInline(admin.TabularInline):
model = Executor
insert_after = 'status'
extra = 1
class ApplicationAdmin(admin.ModelAdmin):
inlines = [ExecutorInline]
admin.site.register(Application, ApplicationAdmin)
views.py
def application_detail(request, pk):
post = get_object_or_404(Application, pk=pk)
own = get_object_or_404(Executor, pk=request.user.id)
return render(request, 'helpdesk/application_detail.html', {'post': post, 'own': own})
html
<li>Исполнитель(и): {{own.owner.get_full_name}}