Good day. I can not solve the issue. There are models:
class TbCompany(models.Model): name = models.CharField( max_length=256) class TbVacancy(models.Model): company = models.ForeignKey( 'TbCompany', on_delete=models.SET_NULL, related_name='companies') position_of_work = models.CharField( max_length=256) class TbVacancyWorker(models.Model): vacancy = models.ForeignKey( 'TbVacancy', on_delete=models.SET_NULL, related_name='vacancies') name = models.CharField( max_length=256) urls.py
url(r'^vacancy/list/$', vacancy_list, name = 'vacancy_list'), url(r'^vacancy/(?P<pk>\d+)/$', vacancy_detail, name = 'vacancy_detail') vacancy_list.html
{% for company in companies %} <P>{{company.name}}</p> {% if company.companies.all.count > 0%} <table class="table table-hover"> <thead> <tr> <th><a href="#">№</a></th> <th><a href="#">Stanowisko</a></th> </tr> </thead> <tbody> {% for i in company.companies.all%} <tr> <td>{{ forloop.counter }}</td> <td><a href="{% КАКОЙ URL СЮДА ПЕРЕДАТЬ %}">{{i.position_of_work}}</a></td> </tr> {% endfor %} </tbody> </table> </div> {% endif %}{% endfor %} wiews.py
def vacancy_list(request): companies = TbCompany.objects.all() return render(request, 'vacancy/vacancy_test.html', {'companies':companies}) It is necessary to display a table with a list of tables with job titles. At the same time there should be links to job details. thank