'How to present only one data with foreign key in Django?
what happens is that I am using a foreign key in a form and it is presented as a select, the thing is that all the information appears and I only want to present the name of the client, however the name, the model of the car and much more information appears to me, how can I present only one data?
carros-form-add.html
<div class="row mb-3">
<div class="col-md-4">
<div class="mb-3">
<label>Cliente</label>
{{ form.cliente }}
</div>
</div>
</div>
carros/models.py
cliente= models.ForeignKey(Clientes, on_delete=models.SET_NULL, null=True)
carros/models.py
class Clientes(models.Model):
tipo = models.CharField(max_length=200)
TITLE = (
('Mrs.', 'Mrs.'),
('Miss', 'Miss'),
('Mr.', 'Mr.'),
)
corp=models.CharField(max_length=200)
title= models.CharField(max_length=200, null=True, choices=TITLE,default='Mr.')
name= models.CharField(max_length=200)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

