Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8198193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:54:00+00:00 2026-06-07T05:54:00+00:00

I have a form with wtform , I want to add a new form

  • 0

I have a form with wtform, I want to add a new form JobItemForm to my form JobForm using append_entry. JobItemForm has selectField named company. I add choice field data via model like this

form.jobs[0].company.choices = company_list

now I use append_entry without any choices and I recieve an error. So how can I call append_entry with some initial data?

class JobItemForm(Form):
    company = SelectField(_('company'), description=_('<a href="/education/institute/add/">new company"</a>'))
    title = TextField(_('title'), [validators.Length(min=4, max=250)])
    date_from = DateField(_("date_from"), format='%Y-%m-%d')
    date_to = DateField(_("date_to"), format='%Y-%m-%d')
    description = TextAreaField(_('description'))


class JobForm(Form):
    jobs = FieldList(FormField(JobItemForm), min_entries=3)
    add_job = SubmitField(_('Add job'))

some thing like this

@mod.route('/edit/', methods=['GET', 'POST'])
@login_required
def edit_job():
    """
    edit job
    """
    company_list = Company.Company_list()
    form_title = "Edit job Form"
    if request.method != 'POST':
        form = JobForm()
        form.jobs[0].company.choices = company_list
        return render('form.html', form=form, form_title=form_title)
    form = JobForm(request.form)
    if form.add_job.data:
        new_item_job = form.jobs.append_entry()
        new_item_job.company.choices = company_list
        return render('form.html', form=form, form_title=form_title)

    form.validate
    if form.errors != dict():
        return render('form.html', form=form, form_title=form_title)
    # save data
    flash(_("Edit successfully!"))
    return render('registration/succesful.html')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:54:01+00:00Added an answer on June 7, 2026 at 5:54 am

    There is a better way to do this:

        form.jobs[0].company.choices = company_list
    

    Wtforms has extensions for GAE,Django and SQLAlchemy which supports orm backed form fields. Documentation of extensions.

    For sqlalchemy, it works like this:

        from wtforms.ext.sqlalchemy.fields import QuerySelectField
    
        def fill_field():
             return Model.query
    
        myfield = QuerySelectField(query_factory=fill_field)
    

    This snippet of code automatically fills the choices for you from the database model.

    (I do not have you actual error so I am just guessing here)

    The reason you are getting no choices error after add_job because you are filling choices only when it is a GET request. You need to add choices after a Post request too like this:

        def your_view():
            form = YourForm()
            form.fieldname.choices = choice_list
            # Here comes your code for GET and POST request both
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SelectField that I want to add validation to with WTForms. The
I have form with few buttons and I want to know what button is
I have form, where some fields are looks like rows, so I can add/delete
I have form in my page, I am using ajax.beginform(). Inside this form I
I have form with multiple input type=radio with text next to them. I want
I have form like this : <div id='add_field' class='locbutton'><a href='#' title='Add'>Add</a></div> <div id='remove_field' class='locbutton2'><a
I have form and form text field which generates dynamically using JSP. And I'm
I have form in VB.Net 2010: I want to click-drag multi rows in dgRegister
I have form to upload images.. what i want is to process the form
i have form and i am using jquery validate jquery.validate.pack.js its work fine when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.