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
  • 1 View
  • 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 have a listbox that a user can select multiple values from . each
I have a ModelForm with a ModelMultipleChoiceField. users = forms.ModelMultipleChoiceField( widget=forms.SelectMultiple(attrs={'class': 'chzn-select'}), queryset =
I have a Listbox that allows user to select multiple items. Normally user can
I don't understand what's happening, I have in my form mylist = forms.MultipleChoiceField(required=False, widget=forms.SelectMultiple,
I have a sql query that looks like this: SELECT SUM(A) AS expr1 FROM
I have a django form that allows a user to select multiple options: CARDS
I have a select list, currently I have it implemented then when the user
I have multi-select drop down list where in user can select multiple options, now
I have a CheckBoxList where users can select multiple items from the list. I
I have a case where user can select multiple values in the list box

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.