code: def fill_form(form, data):
      
      for (key, value) in data.items():
          if hasattr(form, key):
              if isinstance(value, dict):
                  fill_form(getattr(form, key), value)
              else:
                  getattr(form, key).data = value
      return form
docs: Prefill form with data.
  
      :param form: The form to fill.
      :param data: The data to insert in the form.
      :returns: A pre-filled form.