Can you explain what ur problem briefly. On Tue 27 Nov, 2018 8:54 am Mike Dewhirst <mi...@dewhirst.com.au wrote:
> In the Admin I would like to provide the user with checkboxes against a > list of options not stored in the database. > > Specifically, I want to retrieve a comma separated list of integers from a > model field choices attribute. The model field looks like this: > > menu_links = models.CharField(max_length=LARGE, blank=True, > choices=MENU_LINKS, > default='', > validators=[int_list_validator], > verbose_name='Menu data links', > help_text="These selections control which URLs are displayed in the " > "'Substances and mixtures' menu", > ) > > I'm seeing two problems. > > One is getting such a widget to appear in an admin.StackedInline class. > > Two is creating the data in the above models.CharField from > choices=MENU_LINKS > > Here it is ... > > MENU_LINKS = [ > (1, "ChemIDplus"), > (2, "ChemSpider"), > (3, "NIST Webbook"), > ] > > > In the admin I have tried > > class ProfileFilteredSelectMultiple(admin.widgets.FilteredSelectMultiple): > > def __init__(self, verbose_name='Menu links', is_stacked=False, *args, > **kwargs): > args += (verbose_name,) > args += (is_stacked,) > super(ProfileFilteredSelectMultiple, self).__init__(*args, **kwargs) > > > Then in the nested StackedInline class ... > > class CompanyProfileInline(admin.StackedInline): > > model = CompanyProfile > formfield_overrides = { > CharField: {'widget': ProfileFilteredSelectMultiple}, > } > readonly_fields = (('modified', 'modified_by',)) > fieldsets = ( > ('More detail for company profile', { > 'classes': ('collapse', 'wider'), > 'fields': ( > 'menu_links', > ... > > Any hints or pointers will be appreciated. > > Thanks > > Mike > > -- > 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 https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/a49d990e-67fc-3327-4205-a3b843f7f7ae%40dewhirst.com.au > <https://groups.google.com/d/msgid/django-users/a49d990e-67fc-3327-4205-a3b843f7f7ae%40dewhirst.com.au?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMsYeuE%3Dcxh-AC3e%2BZ9z57TEPMqbGO5CfohyVxuQSFyzJML0zw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.