import os
from django.conf import settings
from annoying.decorators import ajax_request
@ajax_request
def json_images(request, dir_name):
path = os.path.join(settings.MEDIA_ROOT, dir_name)
images = []
for f in os.listdir(path):
if f.endswith("jpg") or f.endswith("png"): # to avoid other files
images.append("%s%s/%s" % (settings.MEDIA_URL, dir_name, f)) # modify the concatenation to fit your neet
return {'images': images}
эта функция возвращает объект json, содержащий все изображения в каталоге внутри MEDIA_ROOT.
требуют пакетов, раздражающих django;)