In [1]:
video = list(Video.objects.all())[-1]

In [2]:
video.pk


Out[2]:
65

In [3]:
gallery = Gallery.objects.get(pk=87)

In [5]:
for image in gallery.images.all():
    print(image.pk)


65
622

In [ ]: