Friday, May 19, 2017

django Select or RadioSelect does not work.

Hi,

Below is my code. If I use
  widget=forms.CheckboxSelectMultiple or SelectMultiple, it works for me.
But if I use Select or RadioSelect (I want only one to be selected): this doesn't work.

If I use 'Select', I get the list of versions  (e.g 5.6 and 5.7). If I select 5.7 and click on 'Upgrade', it returns with a message saying 'Enter the list of values'. Not sure what's wrong with 'Select'?

Thanks in advance.

                self.fields[instance_choice[0]] = forms.MultipleChoiceField(
                    label=_("Available Versions"),
                    required=False,
                    widget=forms.Select(
                        attrs={'class': 'switched',
                               'data-switch-on': 'instance',
                               dataKey: instance_choice[0]}))

                # Populate field with choices
                version_choices = []

                try:
                    # Retrieve the available datastore versions
                    ds_versions = trove_api.trove.datastore_version_list(request, instance.datastore['type'])
                except Exception as e:
                    logging.error("%s: Exception received trying to retrieve datastore versions for datastore %s. "
                                  "Exception is: %s",
                                  __method__, instance.datastore['type'], e)

                for avail_version in ds_versions:
                    version_choices.append((avail_version.name, avail_version.name))

                    self.fields[instance_choice[0]].choices = version_choices

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d4f982d8-1dd3-4415-a80c-9ac28835046a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment