Django - Access ForeignKey value without hitting database Django - Access ForeignKey value without hitting database django django

Django - Access ForeignKey value without hitting database


You can do something like this:

pt_ids = Profile_Tag.objects.values_list('profile', flat=True)

This will return you list of IDs. For model instance, there's another way:

pts = Profile_Tag.objects.all()for pt in pts:    print pt.profile_id