Good day, We have an inline formset where each instance of the form has a ManyToManyField for selecting countries. Here is the code:
*# models* *class Geographic_Scope_Region(models.Model):* * # class name exception (underscore) because ManyToManyField assumes pk is lower(Table_Name) + _id* * geographic_scope_region_id = models.AutoField(primary_key=True)* * issf_core = models.ForeignKey(Issf_Core)* * REGION_NAME = (* * ('Asia', 'Asia'),* * ('Africa', 'Africa'),* * ('Caribbean', 'Caribbean'),* * ('Europe', 'Europe'),* * ('Latin America', 'Latin America'),* * ('North America', 'North America'),* * ('Oceania', 'Oceania'),* * ('Other', 'Other'),* * )* * region_name = models.CharField(choices=REGION_NAME, max_length=100)* * region_name_other = models.CharField(max_length=100)* * countries = models.ManyToManyField(Country, db_table='geographic_scope_region_country', blank=True)* * class Meta:* * managed = False* * db_table = 'geographic_scope_region'* *# forms* *class GeographicScopeRegionForm(ModelForm):* * class Meta:* * model = Geographic_Scope_Region* * labels = {* * 'region_name': 'Name of region',* * 'region_name_other': 'Other region name',* * 'countries': 'Select country(ies) (if applicable)',* * }* *GeographicScopeRegionInlineFormSet = inlineformset_factory(Issf_Core, Geographic_Scope_Region, form=GeographicScopeRegionForm, extra=2)* *# views* *class GeographicScopeRegionUpdateView(UpdateView):* * model = Issf_Core* * form_class = GeographicScopeRegionInlineFormSet* * success_url = '/'* It works great and produces the following (simplified) output: <https://lh3.googleusercontent.com/-CzxpKsbf0TA/U3ODe-r4ygI/AAAAAAAAAAg/EOTepTR0OSs/s1600/formset.png> By changing the widget from the default SelectMultiple to CheckboxSelectMultiple, the countries multi-select list becomes a set of checkboxes, one for each of ~200 countries! We're wondering if there's an easy way to instead use an inline formset for the countries, so that each form instance is a Select widget for picking one country? Thanks in advance, Randal -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3ae0bd25-4970-469b-84bd-e080c209d45c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.