1
Use a radio and a Javascript script to make the action disappear the agency field of the report Model, the problem is that add only the combobox the label does not add up.
Model
class Relatorio(models.Model):
data_inicial = models.DateField(default=timezone.now)
data_final = models.DateField(default=timezone.now)
tipo = models.CharField(max_length=30, choices = TIPOS, default='ENVIO')
usuario = models.ForeignKey(User, on_delete=models.CASCADE)
agencia = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True)
Javascript
<script>
jQuery(document).ready(function($) {
$('input[type="radio"]').change(function(){
if ($(this).is('#id_tipo_1')){
$('#id_agencia, label[for="#id_agencia"]').parent().hide()
}else{
$('#id_agencia, [for="#id_agencia"]').parent().show()
}
});
});
</script>
Demonstration:
Valeu helped me a lot!
– jallisson jallis oliveira band