I have an application where I can have multiple reports example students enrolled in a school and student results per subject and various more. These reports accept very similar report creation criterias for example students enrolled takes the search criteria of date range and student results takes date range and course.
I am using WTF flask form to represent each of these report search criterias form For example:
class StudentsEnrolledReportCriteriaForm(Form):
reportEndDate = DateField(u'End Date', id='reportEndDate')
reportStartDate = DateField(u'Start Date', id='reportStartDate')
class StudentResultsReportCriteriaForm(Form):
reportEndDate = DateField(u'End Date', id='reportEndDate')
reportStartDate = DateField(u'Start Date', id='reportStartDate')
course= TextField(u'Course Subject', id='course')
Now at the time of rendering I want to only have one template to render all the report criteria forms. I was thinking of creating a template then looping through the fields in the flask form to display them in the template. But if I do that I cannot govern the order in which the fields will be diplayed in the template.
For example:
{% for field in wtfForm._fields %}
//Display each of these fields but since its a dictionary the order will not be same everytime
{% endfor %}
Can someone please suggest how I can convert the flask form fields into an ordered list which when passed to the UI can be looped through to render the fields