사용자가 최대 10 개의 이미지를 업로드 할 수 있고 이미지 캡션 및 크레딧을 제공 할 수있는 WTForms 양식이 있습니다. 현재 나는 모든 10 세트의 필드를 선언하지만 이것은 중복되는 것처럼 보입니다. 동적 이름을 사용하여 양식 필드를 만드는 방법이 있나요? 그래서 루프로 작성할 수 있습니까?Flask-WTForms를 사용하여 DRY 방식으로 반복되는 양식 요소를 만들려면 어떻게해야합니까?
class MyForm(Form):
image1 = FileField('Upload')
image1_caption = StringField('Caption')
image1_credit = StringField('Credit')
image2 = FileField('Upload')
image2_caption = StringField('Caption')
image2_credit = StringField('Credit')
# ...through 10 images...
나는 WTForms [필드 인클로저] (http://wtforms.simplecodes.com/docs/0.6/fields.html#field-e)를 찾고 있다고 생각합니다. nclosures). – dirn