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 8966081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:56:56+00:00 2026-06-15T16:56:56+00:00

I understand the SelectField method in WTForms takes can argument choices which has the

  • 0

I understand the SelectField method in WTForms takes can argument choices which has the form…

choices=[("value1", "display of value 1"), ("value2", "display of value 2")]

I need to populate my choices based on a call to the database. I’m using neo4j as my backend, so I can’t use modelforms or the other built-in solutions for populating data in a form.

def get_list_of_things():
    query = 'start n = node:things("*:*") return ID(n), n.display_name;'
    t = cypher.execute(cdb, query)[0]
    for x in t:
        x[0] = str(x[0])
        x[1] = str(x[1])
    things = list(tuple(x) for x in t)
    return things

class SelectAThing(Form):
    thingID = SelectField('Thing name', choices=get_list_of_things())

Running choices = get_list_of_things() does produce a valid list of choices, great, and this basically works.

However, it doesn’t ever seem to update the list of things even when the database does and I return to that form later. If I add things to the db and return, I still see the first list of things.

  • 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-15T16:56:57+00:00Added an answer on June 15, 2026 at 4:56 pm

    No dummy, just don’t put it in the class. Put it in the view code.

    @app.route('/route')
    def routename()
        form = SelectAThing()
        form.orgid.choices=get_joinable_orgs()
    

    I found this tricky because I didn’t realize I could assign to form like it was a regular python object after initializing it in the view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand, from MSDN, that ClassInitialize is to mark a method that will do
I understand I can create an enum like this: public enum MyEnum { ONE(1),
understand that we can write the new values to zend coiguration file using the
I understand how I can change the dns settings for my domains by editing
I understand what System.WeakReference does, but what I can't seem to grasp is a
I understand that there is a *.className selector since there can be multiple html
I understand I can go to http://twitter.github.com/bootstrap/customize.html#components and select the only the components I
I understand you can specify a landscape, for the entire application but what if
I understand that if I pass a value-type ( int , struct , etc.)
understand that in App.Xaml.cs, I can create global variable and properties. How do I

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.