How to set foreign key to str method of a model without making alot of db calls?
I'm having two models
class A(models.Model):
name = models.CharField()
class B(models.Model):
model_a = models.ForeignKey(A)
def __str__(self):
return self.model_a.name
This is making alot of db calls. how to fix it?
​
/r/django
https://redd.it/1cglc6y
>>Click here to continue<<