I am not able to access a field of a relationship in filter, I am bringing the objects through the context of a DetailView.
View Server
class HistoricoProgressoes(DetailView):
model = Servidor
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
if self.object.categoria.id in 'DOC':
context["tipo_progressao_a"] = "Progressões Docente"
context['progressoes_a'] = Progressao.objects.filter(servidor__id=self.object.id)
elif self.object.categoria.id in 'TAE':
context["tipo_progressao_a"] = "Progressões por Capacitação Profissional"
context['progressoes_a'] = Progressao.objects.filter(servidor__id=self.object.id).filter(tipo_progressao_tae=2)\
.order_by('nivel_capacitacao')
context["tipo_progressao_b"] = "Progressões por Mérito Profissional"
context['progressoes_b'] = Progressao.objects.filter(servidor__id=self.object.id).filter(tipo_progressao_tae=1)
return context
In the template below I'm getting the information from the above view, through a for, all of them I get normal just can not get the url of the concierge I'm accessing. The relation is correct because it uses the same form in another scope, the problem is in the filter, which is not bringing the full gateway.
progresses.html
<tbody>
{% for prog_b in progressoes_b %}
<tr>
<td>{{ prog_b.padrao_tae }}</td>
<td>{{ prog_b.data_progressao }}</td>
<td><a href="{{prog_b.portaria.portaria.url}}" target="_blank">{{prog_b.portaria}}</a></td>
<td>{{ prog_b.data_prox_progressao}}</td>
</tbody>
</tr>
{%empty%}