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

  • Home
  • SEARCH
  • 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 4606856
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:37:23+00:00 2026-05-22T00:37:23+00:00

I have a selectmultiple choice widget that gets data from mysql database and displays

  • 0

I have a selectmultiple choice widget that gets data from mysql database and displays to the user.

 list = [(x.pk, x.parameter) for x in Parameter.objects.all()]
 parameters = forms.CharField(label=("Available parameters"),widget=forms.SelectMultiple(choices=list)

For example, currently it will show like [A,B,C] in its choices.

If I delete ‘B’ directly from the database, I should be able to see only [A,C] in the selectmultiple widget(initially I thought there will be a reload and get data from database again), but that doesn’t seem to be the case, it will still display [A,B,C]. I want the selectmultiplet widget to actually show the current database at runtime, or refresh(F5) the page at least {seems to not refresh the widget too}. It will only get the new set of data if I restart the web server.

I think it might be some cache that I need to clear? Appreciate any suggestions.
Thanks

  • 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-05-22T00:37:23+00:00Added an answer on May 22, 2026 at 12:37 am

    You need to put your code in the init method of the form, or pass the choices to the form on form creation:

    def SomeForm(forms.Form):
        def __init__(self, *args, **kwargs):
            choices = [(x.pk, x.parameter) for x in Parameter.objects.all()]
            self.fields['parameters'] = forms.CharField(label="Available parameters", widget=forms.SelectMultiple(choices=choices)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a class called List_Field that, as the name suggests, builds list input
I have a set of data and need to pull out one record for
So I have a program that runs a simulation When you select the model,
I'm currently working on a database which is rather complex, at least for my
Have the following scenario. I have a few form, which essentially have a few
have anyone found a substitution for RJS in Ruby on Rails for play? P.S.
have different files with same name, in different directories. In these files there are
Have an Action delegate and trying to use the ternary operator inside of it
I am searching for multiple image upload just like facebook and found the below
I'm developing a website to deploy my android applications. Users can select multiple android

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.