+class GalleryChoiceForm(forms.ModelForm):
+ subpath = forms.ChoiceField(choices=())
+
+ def __init__(self, *args, **kwargs):
+ super(GalleryChoiceForm, self).__init__(*args, **kwargs)
+ self.fields['subpath'].choices = [(settings.IMAGE_DIR + '/' + x, x) for x in os.listdir(settings.MEDIA_ROOT + settings.IMAGE_DIR)]
+
+ class Meta:
+ model = models.GalleryForDocument
+ fields = ('document', 'subpath',)
+