-
Hey there, images = [ 0, 2, 3, 5, 6, 7, 7] I've set up and reciving the images in MEDIA_ROOT, ? |
Beta Was this translation helpful? Give feedback.
Answered by
dzhuang
Feb 6, 2023
Replies: 1 comment
-
As documented in the doc, those ids are the from garlleryfield import BuiltInGalleryImage
images = [ 0, 2, 3, 5, 6, 7, 7]
img_urls = []
for pk in images:
img_urls.append(BuiltInGalleryImage.objects.get(pk=pk).url)
print(img_urls) Or more simpler, if the img_urls = [img.url for img in my_gallery.images.objects.all()] The latter is better as you don't need to know the actual model of the image instances. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
reinatch
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As documented in the doc, those ids are the
pk
s of thetarget_model
instances (which should begarlleryfield.BuiltInGalleryImage
instances if you did not do model customization). You can query the instances through:Or more simpler, if the
Gallery
instance ismy_gallery
, it can be:The latter is better as you don't need to know the actual model of the image instances.