Little new to the Django way of doing things, but I have a series of loops that I am sure can be done more efficiently. Essentially I have a group of related objects that I need to drill down the graph to retrieve the values from the end related object. I am looping down the objects to eventually get the values I want. Please see below code:
for media in campaign.media_set.all():
media_key = media.key
for target in media.target_set.all():
x = target.x
y = target.y
target_id = target.id
for metatag in target.metatag_set.all():
body = metatag.body
hdr = metatag.header
ftr = metatag.footer
ct_url = metatag.clickthrough
point_url = metatag.point.image_file
Any pointers on a way to do this in less DB selects?