I have a django model like so:
class Profile_Tag(models.Model):
profile = models.ForeignKey(Profile)
tag = models.ForeignKey(Tag)
and a view like so:
pts = Profile_Tag.objects.all()
for pt in pts:
print pt.profile.id
is there any way to access the profile foreignKey without hitting the database each time? I don't want to query the profile table. I just want to grab the ids from the Profile_Tag table.
pt.profile.id
results in a query whilept.profile_id
does not. It's possible for them to make the call to.id
not result in a hit so it's possible this may change in the future (or already is different, I haven't tested newer versions). – Friede