I'm creating a dictionary for my model and use the dictionary to make json data.
class MyImage(models.Model):
...
album = models.ForeignKey(Album)
def to_dict(self):
result = {}
result['id'] = self.id
.. additional data...
result['album_id'] = self.album.id // database hit
result['album_title'] = self.album.title // another database hit
result['album_something'] = self.album.something // another hit
I just found out that to create a dictionary of MyImage I need 1+3 as noted in the comment above.
Can I cut down the DB hit to 1+1 instead of 1+3 somehow?