title: How to get SelectField current value with Flask WTF
body: <p>I making a gender form using <strong>Flask-WTF</strong>, here is the snippet of my code:</p>
  
  <pre><code>class Gender(enum.Enum):
      Male = 'Male'
      Female = 'Female'
  
      def __str__(self):
          return self.value
  
  gender = [(str(y), y) for y in (Gender)]
  
  class EditStudentForm(Form):
      gender = SelectField('Gender', choices=gender)
  
  @app.route('/edit_student')
  def edit_student():
      student = Student.query.filter_by(id=student_id).first()
      student_form = EditStudentForm()
      # ... validate on submit
          # ....
          # ....
      return render_template(student=student, student_form=student_form)
  </code></pre>
  
  <p>That code already works, included I can insert the data to the database.</p>
  
  <p><a href="https://i.stack.imgur.com/Jqnwj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jqnwj.png" alt="enter image description here"></a></p>
  
  <p>But, if the current user gender value on database is Female, whenever I refresh the browsers, the form did not get the current value.</p>
  
  <p>In HTML I want it to be like this:</p>
  
  <pre><code>// edit form
  &lt;form&gt;
    &lt;input type="" value="currentUserValueFromDatabase"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I try to get current value using this way:</p>
  
  <pre><code>{{ f.render_field(student_form.gender, value=student.gender) }}
  </code></pre>
  
  <p>But it didn't prepopulate the current value from current user gender.</p>
  
  <p>So what I want is to to display current value on selectfield or prepopulate the selectfield according to the current user value on the database.</p>