Olá, sou novo no django e tenho o seguinte problema, tenho duas classes no django uma delas é :
class Apps(models.Model):
id = models.UUIDField(db_column='ID', primary_key=True) # Field name made lowercase.
name = models.CharField(db_column='Name', max_length=255) # Field name made lowercase.
appid = models.CharField(db_column='AppId', max_length=500, blank=True, null=True) # Field name made lowercase.
publishtime = models.DateTimeField(db_column='PublishTime') # Field name made lowercase.
published = models.BooleanField(db_column='Published') # Field name made
class Meta:
managed = False
db_table = 'Apps'
E a outra é essa :
class Executionresults(models.Model):
id = models.UUIDField(db_column='ID', primary_key=True) # Field name made lowercase.
taskid = models.UUIDField(db_column='TaskID') # Field name made lowercase.
executionid = models.UUIDField(db_column='ExecutionID') # Field name made lowercase.
appid = models.UUIDField(db_column='AppID') # Field name made lowercase.
executingnodeid = models.UUIDField(db_column='ExecutingNodeID') # Field name made lowercase.
status = models.IntegerField(db_column='Status') # Field name made
Gostaria de saber como comparar dois valores, se o "appid" da tabela "Apps" for igual ao "appid" da tabela "Executionresults" ele tem que me retornar o "name" da tabela "Apps".
Tentei fazer isso no direto no index.html, porem sem sucesso.
<table class="table table-striped up">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Task ID</th>
<th scope="col">Inicio</th>
<th scope="col">Fim</th>
<th scope="col">Nome App</th>
<th scope="col">status</th>
</tr>
</thead>
<tbody>
{% for exe in executionresults %}
{% for app in apps %}
<tr>
<th scope="row"></th>
<td>{{ exe.taskid }}</td>
<td>{{ exe.starttime }}</td>
<td>{{ exe.stoptime }}</td>
{% if exe.appid == app.targetappid %}
<td>{{ return app.name }}</td>
{%endif%}
{% if exe.status == 1 %}
<td style="text-align: center;"class="alert alert-danger" role="alert">Desencadeado <i class="fa fa-check" style="font-size:16px"></i></td>
{%elif exe.status == 2 %}
<td style="text-align: center;"class="alert alert-success" role="alert">Iniciado <i class="fa fa-check" style="font-size:16px"></i></td>
{%elif exe.status == 3 %}
<td style="text-align: center;"class="alert alert-success" role="alert">Na fila <i class="fa fa-check" style="font-size:16px"></i></td>
{%elif exe.status == 4 %}
<td style="text-align: center; "class="alert alert-warning" role="alert">Abortar iniciado <i class="fa fa-exclamation" style="font-size:20px"></i></td>
{%elif exe.status == 5 %}
<td style="text-align: center; "class="alert alert-warning" role="alert">Abortando <i class="fa fa-exclamation" style="font-size:20px"></i></td>
{%elif exe.status == 6 %}
<td style="text-align: center;"class="alert alert-danger" role="alert">Abortado <i class=" fa fa-close" style="font-size:20px"></i></td>
{% elif exe.status == 7 %}
<td style="text-align: center;"class="alert alert-success" role="alert">Finalizado com sucesso <i class="fa fa-check" style="font-size:16px"></i></td>
{%elif exe.status == 8 %}
<td style="text-align: center;"class="alert alert-danger" role="alert">Falha! <i class=" fa fa-close" style="font-size:20px"></i></td>
{%elif exe.status == 9 %}
<td style="text-align: center; "class="alert alert-warning" role="alert">Pulou <i class="fa fa fa-exclamation" style="font-size:20px"></i></td>
{%elif exe.status == 10 %}
<td style="text-align: center;"class="alert alert-danger" role="alert">Tente novamente <i class="fa fa-close" style="font-size:20px"></i></td>
{%elif exe.status == 11 %}
<td style="text-align: center;"class="alert alert-danger" role="alert">Erro! <i class=" fa fa-close" style="font-size:20px"></i></td>
{%elif exe.status == 12 %}
<td style="text-align: center;"class="alert alert-danger" role="alert">Restabelecer <i class=" fa fa-close" style="font-size:20px"></i></td>
{%else%}
<td>{{ exe.status }}</td>
{%endif%}
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
Meu objetivo final é trazer as tasks da tabela Executionresults, porem nessa tabela não mostra o nome do app, e eu preciso mostrar para o usuário, portanto preciso fazer essa união de tabelas.