The implementation of DocumentDetail's str method works, but is slows everything down by running a bunch of extra queries when I try to use it views, forms, etc. Does anyone know a way around this?
models.py
class Document(models.Model):
description = models.CharField(max_length=50)
def __str__(self):
return self.description
class DocumentDetail(models.Model):
document = models.ForeignKey(Document, on_delete=models.CASCADE)
detail = models.CharField(max_length=50)
def __str__(self):
return self.document.description